Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45686b4

Browse files
committed
Correcting issue 12576 fix, which resulted in buildbot failures.
1 parent f25e3d5 commit 45686b4

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Lib/urllib/request.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,13 +1135,10 @@ def do_open(self, http_class, req, **http_conn_args):
11351135
try:
11361136
h.request(req.get_method(), req.selector, req.data, headers)
11371137
except socket.error as err: # timeout error
1138+
h.close()
11381139
raise URLError(err)
1139-
finally:
1140-
try:
1141-
r = h.getresponse() # an HTTPResponse instance
1142-
except Exception as exp:
1143-
h.close()
1144-
raise exp
1140+
else:
1141+
r = h.getresponse()
11451142

11461143
r.url = req.get_full_url()
11471144
# This line replaces the .msg attribute of the HTTPResponse

0 commit comments

Comments
 (0)