Issue #15841: The readable(), writable() and seekable() methods of io.BytesIO
and io.StringIO objects now raise ValueError when the object has been closed.
Patch by Alessandro Moura.
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index d511433..86f3c4c 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -883,12 +883,18 @@
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
@@ -1546,6 +1552,8 @@
return self._buffer
def seekable(self):
+ if self.closed:
+ raise ValueError("I/O operation on closed file.")
return self._seekable
def readable(self):