diff options
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a09a35348c..1dda966a23 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1134,11 +1134,11 @@ class AbstractHTTPHandler(BaseHandler): try: h.request(req.get_method(), req.selector, req.data, headers) - r = h.getresponse() # an HTTPResponse instance - except socket.error as err: - raise URLError(err) - finally: + except socket.error as err: # timeout error h.close() + raise URLError(err) + else: + r = h.getresponse() r.url = req.get_full_url() # This line replaces the .msg attribute of the HTTPResponse |