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.
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":
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)
(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