diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2018-12-29 01:42:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-29 01:42:16 (GMT) |
commit | 1f511e1af060e98fb789319a96076c06e7f98135 (patch) | |
tree | 42e1290e446d69815b65dc95831cd681db345e59 /Lib | |
parent | 5471420faa84519530f29b08f2b042b2288e3e96 (diff) | |
download | cpython-1f511e1af060e98fb789319a96076c06e7f98135.zip cpython-1f511e1af060e98fb789319a96076c06e7f98135.tar.gz cpython-1f511e1af060e98fb789319a96076c06e7f98135.tar.bz2 |
Make sure file object is close if socket.create_connection fails (GH-11334)
The problem affects _testWithTimeoutTriggeredSend in test_socket.py.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_socket.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 36d3d5e..7c5167d 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -5787,11 +5787,10 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest): def _testWithTimeoutTriggeredSend(self): address = self.serv.getsockname() - file = open(support.TESTFN, 'rb') - with socket.create_connection(address, timeout=0.01) as sock, \ - file as file: - meth = self.meth_from_sock(sock) - self.assertRaises(socket.timeout, meth, file) + with open(support.TESTFN, 'rb') as file: + with socket.create_connection(address, timeout=0.01) as sock: + meth = self.meth_from_sock(sock) + self.assertRaises(socket.timeout, meth, file) def testWithTimeoutTriggeredSend(self): conn = self.accept_conn() |