Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9ea7c0

Browse files
committed
[Patch #988504] Fix HTTP error handling via a patch from John J. Lee
1 parent 42851ab commit f9ea7c0

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Lib/urllib2.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -996,16 +996,12 @@ def do_open(self, http_class, req):
996996
except socket.error, err: # XXX what error?
997997
raise URLError(err)
998998

999-
if r.status in (200, 206):
1000-
# Pick apart the HTTPResponse object to get the addinfourl
1001-
# object initialized properly
1002-
resp = addinfourl(r.fp, r.msg, req.get_full_url())
1003-
resp.code = r.status
1004-
resp.msg = r.reason
1005-
return resp
1006-
else:
1007-
return self.parent.error("http", req, r.fp, r.status, r.msg,
1008-
r.msg.dict)
999+
# Pick apart the HTTPResponse object to get the addinfourl
1000+
# object initialized properly
1001+
resp = addinfourl(r.fp, r.msg, req.get_full_url())
1002+
resp.code = r.status
1003+
resp.msg = r.reason
1004+
return resp
10091005

10101006

10111007
class HTTPHandler(AbstractHTTPHandler):

0 commit comments

Comments
 (0)