Skip to content

Commit 1f511e1

Browse files
authored
Make sure file object is close if socket.create_connection fails (pythonGH-11334)
The problem affects _testWithTimeoutTriggeredSend in test_socket.py.
1 parent 5471420 commit 1f511e1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/test/test_socket.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5787,11 +5787,10 @@ def testWithTimeout(self):
57875787

57885788
def _testWithTimeoutTriggeredSend(self):
57895789
address = self.serv.getsockname()
5790-
file = open(support.TESTFN, 'rb')
5791-
with socket.create_connection(address, timeout=0.01) as sock, \
5792-
file as file:
5793-
meth = self.meth_from_sock(sock)
5794-
self.assertRaises(socket.timeout, meth, file)
5790+
with open(support.TESTFN, 'rb') as file:
5791+
with socket.create_connection(address, timeout=0.01) as sock:
5792+
meth = self.meth_from_sock(sock)
5793+
self.assertRaises(socket.timeout, meth, file)
57955794

57965795
def testWithTimeoutTriggeredSend(self):
57975796
conn = self.accept_conn()

0 commit comments

Comments
 (0)