diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-09-05 18:11:49 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-09-05 18:11:49 (GMT) |
commit | 1d857453b7065dafdc34a72c1bbb2a993782b383 (patch) | |
tree | e1ba8cd8fd1fb6d2b811e96632e8efefa97a2d51 /Lib/_pyio.py | |
parent | 397e5c98bc27416fe8a407e39e4c5aa4baf94423 (diff) | |
download | cpython-1d857453b7065dafdc34a72c1bbb2a993782b383.zip cpython-1d857453b7065dafdc34a72c1bbb2a993782b383.tar.gz cpython-1d857453b7065dafdc34a72c1bbb2a993782b383.tar.bz2 |
Issue #15841: The readable(), writable() and seekable() methods of BytesIO
and StringIO objects now raise ValueError when the object has been closed.
Patch by Alessandro Moura.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index a2faeb3..2d376d8 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -889,12 +889,18 @@ class BytesIO(BufferedIOBase): return pos def readable(self): + if self.closed: + raise ValueError("I/O operation on closed file.") return True def writable(self): + if self.closed: + raise ValueError("I/O operation on closed file.") return True def seekable(self): + if self.closed: + raise ValueError("I/O operation on closed file.") return True @@ -1567,6 +1573,8 @@ class TextIOWrapper(TextIOBase): return self._buffer def seekable(self): + if self.closed: + raise ValueError("I/O operation on closed file.") return self._seekable def readable(self): |