diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-03-31 07:21:56 +0000 |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-03-31 07:21:56 +0000 |
commit | 754aab28ed5f94338641db8899f89f59895c2137 (patch) | |
tree | 79c911c8dd0bc6f25f0d454e3c26608579171fb8 /Lib/_pyio.py | |
parent | Issue #26492: Added additional tests for exhausted iterators of mutable seque... (diff) | |
download | cpython-754aab28ed5f94338641db8899f89f59895c2137.tar.gz cpython-754aab28ed5f94338641db8899f89f59895c2137.tar.bz2 cpython-754aab28ed5f94338641db8899f89f59895c2137.zip |
Issue #22854: Clarify documentation about UnsupportedOperation and add tests
Also change BufferedReader.writable() and BufferedWriter.readable() to always
return False.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 37157d53ab4..a467ddda4ff 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -390,7 +390,7 @@ class IOBase(metaclass=abc.ABCMeta): def seekable(self): """Return a bool indicating whether object supports random access. - If False, seek(), tell() and truncate() will raise UnsupportedOperation. + If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek(). """ return False @@ -405,7 +405,7 @@ class IOBase(metaclass=abc.ABCMeta): def readable(self): """Return a bool indicating whether object was opened for reading. - If False, read() will raise UnsupportedOperation. + If False, read() will raise OSError. """ return False @@ -419,7 +419,7 @@ class IOBase(metaclass=abc.ABCMeta): def writable(self): """Return a bool indicating whether object was opened for writing. - If False, write() and truncate() will raise UnsupportedOperation. + If False, write() and truncate() will raise OSError. """ return False @@ -787,12 +787,6 @@ class _BufferedIOMixin(BufferedIOBase): def seekable(self): return self.raw.seekable() - def readable(self): - return self.raw.readable() - - def writable(self): - return self.raw.writable() - @property def raw(self): return self._raw @@ -982,6 +976,9 @@ class BufferedReader(_BufferedIOMixin): self._reset_read_buf() self._read_lock = Lock() + def readable(self): + return self.raw.readable() + def _reset_read_buf(self): self._read_buf = b"" self._read_pos = 0 @@ -1170,6 +1167,9 @@ class BufferedWriter(_BufferedIOMixin): self._write_buf = bytearray() self._write_lock = Lock() + def writable(self): + return self.raw.writable() + def write(self, b): if self.closed: raise ValueError("write to closed file") |