AbstractHTTPHandler.do_open() of urllib.request closes the HTTP connection if
its getresponse() method fails with a socket error. Patch written by Ezio
Melotti.
def getresponse(self):
return MockHTTPResponse(MockFile(), {}, 200, "OK")
+ def close(self):
+ pass
+
class MockHandler:
# useful for testing handler machinery
# see add_ordered_mock_handlers() docstring
r = h.getresponse() # an HTTPResponse instance
except socket.error as err:
raise URLError(err)
+ finally:
+ h.close()
r.url = req.get_full_url()
# This line replaces the .msg attribute of the HTTPResponse
Library
-------
+- Issue #12133: AbstractHTTPHandler.do_open() of urllib.request closes the HTTP
+ connection if its getresponse() method fails with a socket error. Patch
+ written by Ezio Melotti.
+
- Issue #9284: Allow inspect.findsource() to find the source of doctest
functions.