summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index c000f11..7b2f1f7 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -326,11 +326,12 @@ class URLopener:
if data is not None:
h.send(data)
errcode, errmsg, headers = h.getreply()
+ fp = h.getfile()
if errcode == -1:
+ if fp: fp.close()
# something went wrong with the HTTP status line
raise IOError, ('http protocol error', 0,
'got a bad status line', None)
- fp = h.getfile()
if errcode == 200:
return addinfourl(fp, headers, "http:" + url)
else:
@@ -417,11 +418,12 @@ class URLopener:
if data is not None:
h.send(data)
errcode, errmsg, headers = h.getreply()
+ fp = h.getfile()
if errcode == -1:
+ if fp: fp.close()
# something went wrong with the HTTP status line
raise IOError, ('http protocol error', 0,
'got a bad status line', None)
- fp = h.getfile()
if errcode == 200:
return addinfourl(fp, headers, "https:" + url)
else: