mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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:
parent
80f4553d56
commit
c5eec0e387
6 changed files with 47 additions and 12 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue