]> granicus.if.org Git - python/commitdiff
reject None as the buffering argument like the C implementation does #8546
authorBenjamin Peterson <benjamin@python.org>
Tue, 27 Apr 2010 21:01:54 +0000 (21:01 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 27 Apr 2010 21:01:54 +0000 (21:01 +0000)
Doc/library/io.rst
Lib/_pyio.py
Misc/NEWS

index adde553c51d6c64d3efa559f66694115ebc524a0..cf5e9f766d2179ce88963d824fd7495b15234a88 100644 (file)
@@ -61,7 +61,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 809868106769c470e8e082174b9e3cba2d5df6d6..cafc51ccc7654b9bc53c2890fc35b32763941655 100644 (file)
@@ -40,7 +40,7 @@ class BlockingIOError(IOError):
         self.characters_written = characters_written
 
 
-def open(file, mode="r", buffering=None,
+def open(file, mode="r", buffering=-1,
          encoding=None, errors=None,
          newline=None, closefd=True):
 
@@ -155,7 +155,7 @@ def open(file, mode="r", buffering=None,
         raise TypeError("invalid file: %r" % file)
     if not isinstance(mode, basestring):
         raise TypeError("invalid mode: %r" % mode)
-    if buffering is not None and not isinstance(buffering, (int, long)):
+    if not isinstance(buffering, (int, long)):
         raise TypeError("invalid buffering: %r" % buffering)
     if encoding is not None and not isinstance(encoding, basestring):
         raise TypeError("invalid encoding: %r" % encoding)
@@ -192,8 +192,6 @@ def open(file, mode="r", buffering=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 2c2d2f283b6f49d54e682afdfae246247d6e8740..de05472f56a05a4ed61e384e13b7bf92d81b87d1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,8 @@ Core and Builtins
 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.