summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:14:08 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:14:08 (GMT)
commit5d5381ed002a03486b7364f9ae8b69fa2d2a1ede (patch)
treeba7cb90afdfceb2bfe0fa733710abcd5227baf36 /Lib/socket.py
parent7d9d34f18ab8a103e2ba7077293b49c861236547 (diff)
downloadcpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.zip
cpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.tar.gz
cpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.tar.bz2
Merged revisions 88622 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88622 | antoine.pitrou | 2011-02-26 00:07:44 +0100 (sam., 26 févr. 2011) | 5 lines Issue #7322: Trying to read from a socket's file-like object after a timeout occurred now raises an error instead of silently losing data. Patch by Ross Lagerwall. ........
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 95901ae..1e28549 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -257,6 +257,7 @@ class SocketIO(io.RawIOBase):
self._mode = mode
self._reading = "r" in mode
self._writing = "w" in mode
+ self._timeout_occurred = False
def readinto(self, b):
"""Read up to len(b) bytes into the writable buffer *b* and return
@@ -268,9 +269,14 @@ class SocketIO(io.RawIOBase):
"""
self._checkClosed()
self._checkReadable()
+ if self._timeout_occurred:
+ raise IOError("cannot read from timed out object")
while True:
try:
return self._sock.recv_into(b)
+ except timeout:
+ self._timeout_occurred = True
+ raise
except error as e:
n = e.args[0]
if n == EINTR: