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.
This commit is contained in:
Antoine Pitrou 2012-09-05 20:13:48 +02:00
commit 11946fbe80
6 changed files with 47 additions and 12 deletions

View file

@ -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):