Issue #15842: the SocketIO.{readable,writable,seekable} methods now raise ValueError when the file-like object is closed.

Patch by Alessandro Moura.
This commit is contained in:
Antoine Pitrou 2012-09-14 17:30:31 +02:00
commit 9b1c84b586
3 changed files with 28 additions and 2 deletions

View file

@ -324,12 +324,23 @@ class SocketIO(io.RawIOBase):
def readable(self):
"""True if the SocketIO is open for reading.
"""
return self._reading and not self.closed
if self.closed:
raise ValueError("I/O operation on closed socket.")
return self._reading
def writable(self):
"""True if the SocketIO is open for writing.
"""
return self._writing and not self.closed
if self.closed:
raise ValueError("I/O operation on closed socket.")
return self._writing
def seekable(self):
"""True if the SocketIO is open for seeking.
"""
if self.closed:
raise ValueError("I/O operation on closed socket.")
return super().seekable()
def fileno(self):
"""Return the file descriptor of the underlying socket.