summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-17 12:02:18 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-17 12:02:18 (GMT)
commitf073dc286c0d489dfb71046df0358a49e8a26086 (patch)
tree115f2e083978b9c6e97f15216e73fee8baeddf75 /Lib/urllib
parent723993983a8227d7f068b072657caa2b75d4413c (diff)
parenta4c45d73cf6eeb8ede6ee701c0372d7e45dc24f2 (diff)
downloadcpython-f073dc286c0d489dfb71046df0358a49e8a26086.zip
cpython-f073dc286c0d489dfb71046df0358a49e8a26086.tar.gz
cpython-f073dc286c0d489dfb71046df0358a49e8a26086.tar.bz2
(Merge 3.2) Issue #12133: fix a ResourceWarning in urllib.request
AbstractHTTPHandler.do_open() of urllib.request closes the HTTP connection if its getresponse() method fails with a socket error. Patch written by Ezio Melotti.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index e98a976..316e0f9 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1146,6 +1146,8 @@ class AbstractHTTPHandler(BaseHandler):
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