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.
This commit is contained in:
Antoine Pitrou 2012-09-05 20:11:49 +02:00
parent 80f4553d56
commit c5eec0e387
6 changed files with 47 additions and 12 deletions

View file

@ -883,12 +883,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
@ -1546,6 +1552,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):