mirror of https://github.com/python/cpython
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).
This commit is contained in:
parent
6cbd8de641
commit
ce55e21c70
|
@ -326,11 +326,12 @@ class URLopener:
|
||||||
if data is not None:
|
if data is not None:
|
||||||
h.send(data)
|
h.send(data)
|
||||||
errcode, errmsg, headers = h.getreply()
|
errcode, errmsg, headers = h.getreply()
|
||||||
|
fp = h.getfile()
|
||||||
if errcode == -1:
|
if errcode == -1:
|
||||||
|
if fp: fp.close()
|
||||||
# something went wrong with the HTTP status line
|
# something went wrong with the HTTP status line
|
||||||
raise IOError, ('http protocol error', 0,
|
raise IOError, ('http protocol error', 0,
|
||||||
'got a bad status line', None)
|
'got a bad status line', None)
|
||||||
fp = h.getfile()
|
|
||||||
if errcode == 200:
|
if errcode == 200:
|
||||||
return addinfourl(fp, headers, "http:" + url)
|
return addinfourl(fp, headers, "http:" + url)
|
||||||
else:
|
else:
|
||||||
|
@ -417,11 +418,12 @@ class URLopener:
|
||||||
if data is not None:
|
if data is not None:
|
||||||
h.send(data)
|
h.send(data)
|
||||||
errcode, errmsg, headers = h.getreply()
|
errcode, errmsg, headers = h.getreply()
|
||||||
|
fp = h.getfile()
|
||||||
if errcode == -1:
|
if errcode == -1:
|
||||||
|
if fp: fp.close()
|
||||||
# something went wrong with the HTTP status line
|
# something went wrong with the HTTP status line
|
||||||
raise IOError, ('http protocol error', 0,
|
raise IOError, ('http protocol error', 0,
|
||||||
'got a bad status line', None)
|
'got a bad status line', None)
|
||||||
fp = h.getfile()
|
|
||||||
if errcode == 200:
|
if errcode == 200:
|
||||||
return addinfourl(fp, headers, "https:" + url)
|
return addinfourl(fp, headers, "https:" + url)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue