Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95e392c

Browse files
committed
Merged revisions 80544 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent 06e34a9 commit 95e392c

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

Doc/library/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Module Interface
5656
classes. :func:`.open` uses the file's blksize (as obtained by
5757
:func:`os.stat`) if possible.
5858

59-
.. function:: open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True)
59+
.. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
6060

6161
Open *file* and return a corresponding stream. If the file cannot be opened,
6262
an :exc:`IOError` is raised.

Lib/_pyio.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, errno, strerror, characters_written=0):
3535
self.characters_written = characters_written
3636

3737

38-
def open(file: (str, bytes), mode: str = "r", buffering: int = None,
38+
def open(file: (str, bytes), mode: str = "r", buffering: int = -1,
3939
encoding: str = None, errors: str = None,
4040
newline: str = None, closefd: bool = True) -> "IOBase":
4141

@@ -150,7 +150,7 @@ def open(file: (str, bytes), mode: str = "r", buffering: int = None,
150150
raise TypeError("invalid file: %r" % file)
151151
if not isinstance(mode, str):
152152
raise TypeError("invalid mode: %r" % mode)
153-
if buffering is not None and not isinstance(buffering, int):
153+
if not isinstance(buffering, int):
154154
raise TypeError("invalid buffering: %r" % buffering)
155155
if encoding is not None and not isinstance(encoding, str):
156156
raise TypeError("invalid encoding: %r" % encoding)
@@ -187,8 +187,6 @@ def open(file: (str, bytes), mode: str = "r", buffering: int = None,
187187
(appending and "a" or "") +
188188
(updating and "+" or ""),
189189
closefd)
190-
if buffering is None:
191-
buffering = -1
192190
line_buffering = False
193191
if buffering == 1 or buffering < 0 and raw.isatty():
194192
buffering = -1

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ C-API
339339
Library
340340
-------
341341

342+
- Issue #8546: Reject None given as the buffering argument to _pyio.open.
343+
342344
- Issue #8549: Fix compiling the _ssl extension under AIX. Patch by
343345
Sridhar Ratnakumar.
344346

0 commit comments

Comments
 (0)