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.
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index abc84b1..2641619 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -1172,6 +1172,8 @@
r = h.getresponse()
except socket.error, err: # XXX what error?
raise URLError(err)
+ finally:
+ h.close()
# Pick apart the HTTPResponse object to get the addinfourl
# object initialized properly.