mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
commit
11946fbe80
6 changed files with 47 additions and 12 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue