diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-02-25 23:07:44 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-02-25 23:07:44 (GMT) |
commit | 68e5c044e898c474750baeaee3234be8e27b5607 (patch) | |
tree | ca1deb15535e8a4b352b052406bc3e539db71836 /Lib/test/test_socket.py | |
parent | fc1cf41911fcb91da0802ebc4e49e7f342f59e21 (diff) | |
download | cpython-68e5c044e898c474750baeaee3234be8e27b5607.zip cpython-68e5c044e898c474750baeaee3234be8e27b5607.tar.gz cpython-68e5c044e898c474750baeaee3234be8e27b5607.tar.bz2 |
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/test/test_socket.py')
-rw-r--r-- | Lib/test/test_socket.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 9d5d8ca..5a5a214 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1109,6 +1109,23 @@ class FileObjectClassTestCase(SocketConnectedTest): self.write_file = None SocketConnectedTest.clientTearDown(self) + def testReadAfterTimeout(self): + # Issue #7322: A file object must disallow further reads + # after a timeout has occurred. + self.cli_conn.settimeout(1) + self.read_file.read(3) + # First read raises a timeout + self.assertRaises(socket.timeout, self.read_file.read, 1) + # Second read is disallowed + with self.assertRaises(IOError) as ctx: + self.read_file.read(1) + self.assertIn("cannot read from timed out object", str(ctx.exception)) + + def _testReadAfterTimeout(self): + self.write_file.write(self.write_msg[0:3]) + self.write_file.flush() + self.serv_finished.wait() + def testSmallRead(self): # Performing small file read test first_seg = self.read_file.read(len(self.read_msg)-3) |