Fix how the http error doesn't always have the response attached

in earlier versions of requests (pre 0.10.8).
This commit is contained in:
Joshua Harlow 2013-03-13 22:33:18 -07:00
parent 37e6ccff09
commit 481a8b04b2

View File

@ -170,7 +170,9 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
# attrs
return UrlResponse(r)
except exceptions.RequestException as e:
if isinstance(e, (exceptions.HTTPError)) and e.response:
if (isinstance(e, (exceptions.HTTPError))
and hasattr(e, 'response') # This appeared in v 0.10.8
and e.response):
excps.append(UrlError(e, code=e.response.status_code,
headers=e.response.headers))
else: