]> granicus.if.org Git - python/commitdiff
Merged revisions 80544 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Tue, 27 Apr 2010 21:07:21 +0000 (21:07 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 27 Apr 2010 21:07:21 +0000 (21:07 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80544 | benjamin.peterson | 2010-04-27 16:01:54 -0500 (Tue, 27 Apr 2010) | 1 line

  reject None as the buffering argument like the C implementation does #8546
........

Doc/library/io.rst
Lib/_pyio.py
Misc/NEWS

index c3ebe9af003fff0672d2d522818f0a6991666aec..4511ce622cd4bea3be68b4939b5afb08439e1d77 100644 (file)
@@ -56,7 +56,7 @@ Module Interface
    classes.  :func:`.open` uses the file's blksize (as obtained by
    :func:`os.stat`) if possible.
 
-.. function:: open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True)
+.. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
 
    Open *file* and return a corresponding stream.  If the file cannot be opened,
    an :exc:`IOError` is raised.
index c58548e7ee0fd21b4e91b3621975bee521f6cb76..c9c42977007f56406c346ed0bbb5329c3a469406 100644 (file)
@@ -35,7 +35,7 @@ class BlockingIOError(IOError):
         self.characters_written = characters_written
 
 
-def open(file: (str, bytes), mode: str = "r", buffering: int = None,
+def open(file: (str, bytes), mode: str = "r", buffering: int = -1,
          encoding: str = None, errors: str = None,
          newline: str = None, closefd: bool = True) -> "IOBase":
 
@@ -150,7 +150,7 @@ def open(file: (str, bytes), mode: str = "r", buffering: int = None,
         raise TypeError("invalid file: %r" % file)
     if not isinstance(mode, str):
         raise TypeError("invalid mode: %r" % mode)
-    if buffering is not None and not isinstance(buffering, int):
+    if not isinstance(buffering, int):
         raise TypeError("invalid buffering: %r" % buffering)
     if encoding is not None and not isinstance(encoding, str):
         raise TypeError("invalid encoding: %r" % encoding)
@@ -187,8 +187,6 @@ def open(file: (str, bytes), mode: str = "r", buffering: int = None,
                  (appending and "a" or "") +
                  (updating and "+" or ""),
                  closefd)
-    if buffering is None:
-        buffering = -1
     line_buffering = False
     if buffering == 1 or buffering < 0 and raw.isatty():
         buffering = -1
index 2837ef9fe16e113556e565176e3e9400e98bc149..ff469e78aa843e7a06b0f7dea7fee01bbb6a0b00 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -339,6 +339,8 @@ C-API
 Library
 -------
 
+- Issue #8546: Reject None given as the buffering argument to _pyio.open.
+
 - Issue #8549: Fix compiling the _ssl extension under AIX.  Patch by
   Sridhar Ratnakumar.