diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-09-05 20:13:48 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-09-05 20:13:48 +0200 |
commit | 11946fbe804d99d26724e65dcb061cda6666c4e9 (patch) | |
tree | 33d3fac84bc13fdc95c9de2943d10641fe097a21 /Lib/_pyio.py | |
parent | e8677c038f94795f54de324e5d9235636c92afa0 (diff) | |
parent | 1d857453b7065dafdc34a72c1bbb2a993782b383 (diff) | |
download | cpython-git-11946fbe804d99d26724e65dcb061cda6666c4e9.tar.gz |
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 387c58594e..fa77ec17f5 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -895,12 +895,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 @@ -1562,6 +1568,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): |