diff options
author | Guido van Rossum <guido@python.org> | 2007-05-24 00:50:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-24 00:50:02 (GMT) |
commit | c2f93dc2e42b48a20578599407b0bb51a6663d09 (patch) | |
tree | a13677daceceb29f55a468cac3874e1a757dccc9 /Lib/io.py | |
parent | d8595fe304c3d9bb15ad59b1db0b71a2b7ab3c54 (diff) | |
download | cpython-c2f93dc2e42b48a20578599407b0bb51a6663d09.zip cpython-c2f93dc2e42b48a20578599407b0bb51a6663d09.tar.gz cpython-c2f93dc2e42b48a20578599407b0bb51a6663d09.tar.bz2 |
Remove native popen() and fdopen(), replacing them with subprocess calls.
Fix a path to an assert in fileio_read().
Some misc tweaks.
Diffstat (limited to 'Lib/io.py')
-rw-r--r-- | Lib/io.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -120,6 +120,8 @@ def open(file, mode="r", buffering=None, *, encoding=None, newline=None): (appending and "a" or "") + (updating and "+" or "")) if buffering is None: + buffering = -1 + if buffering < 0: buffering = DEFAULT_BUFFER_SIZE # XXX Should default to line buffering if os.isatty(raw.fileno()) try: @@ -446,8 +448,8 @@ class BufferedIOBase(IOBase): implementation, but wrap one. """ - def read(self, n: int = -1) -> bytes: - """read(n: int = -1) -> bytes. Read and return up to n bytes. + def read(self, n: int = None) -> bytes: + """read(n: int = None) -> bytes. Read and return up to n bytes. If the argument is omitted, None, or negative, reads and returns all data until EOF. @@ -717,6 +719,8 @@ class BufferedWriter(_BufferedIOMixin): self._write_buf = b"" def write(self, b): + if not isinstance(b, bytes): + b = bytes(b) # XXX we can implement some more tricks to try and avoid partial writes if len(self._write_buf) > self.buffer_size: # We're full, so let's pre-flush the buffer |