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

Skip to content

Commit 4d90b19

Browse files
committed
merge from 3.2 - Correcting issue 12576 fix, which resulted in buildbot failures.
2 parents 12aa1ae + 45686b4 commit 4d90b19

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
@@ -1144,13 +1144,10 @@ def do_open(self, http_class, req, **http_conn_args):
11441144
try:
11451145
h.request(req.get_method(), req.selector, req.data, headers)
11461146
except socket.error as err: # timeout error
1147+
h.close()
11471148
raise URLError(err)
1148-
finally:
1149-
try:
1150-
r = h.getresponse() # an HTTPResponse instance
1151-
except Exception as exp:
1152-
h.close()
1153-
raise exp
1149+
else:
1150+
r = h.getresponse()
11541151

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

0 commit comments

Comments
 (0)