summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-09-14 15:28:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-09-14 15:28:10 (GMT)
commit1e7ee9dfa0cc5007da1cbc3331b799584af8b680 (patch)
tree2dc6743ca8f3def1ffbb1eafb5d488322adcd4e2 /Lib/socket.py
parente0add764688a3f3237749e0c2830b669d2c76ca0 (diff)
downloadcpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.zip
cpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.tar.gz
cpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.tar.bz2
Issue #15842: the SocketIO.{readable,writable,seekable} methods now raise ValueError when the file-like object is closed.
Patch by Alessandro Moura.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index a93cd11..ea56a67 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -315,12 +315,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.