diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-03-20 08:14:57 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-03-20 08:14:57 (GMT) |
commit | ce55e21c70068315e128980848f86d1d471fc41c (patch) | |
tree | 7d1d1c3b4862d4ac48c515e2ebe8307a1e8c9968 /Lib/urllib.py | |
parent | 6cbd8de64175327c9d7d088b92f74cbd1c32f3e6 (diff) | |
download | cpython-ce55e21c70068315e128980848f86d1d471fc41c.zip cpython-ce55e21c70068315e128980848f86d1d471fc41c.tar.gz cpython-ce55e21c70068315e128980848f86d1d471fc41c.tar.bz2 |
Try to get test_urllib to pass on Windows by closing the file.
I'm guessing that's the problem. h.getfile() must be called *after*
h.getreply() and the fp can be None.
I'm not entirely convinced this is the best fix (or even correct).
The buildbots will tell us if things improve or not. I don't
know if this needs to be backported (assuming it actually works).
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 6 |
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: |