From 204e79b93c882e17df63b24f7f682c0dbefb482d Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 13 Mar 2013 22:33:18 -0700 Subject: Fix how the http error doesn't always have the response attached in earlier versions of requests (pre 0.10.8). --- cloudinit/url_helper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cloudinit/url_helper.py') diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py index 08e5f01b..bfc5cfdd 100644 --- a/cloudinit/url_helper.py +++ b/cloudinit/url_helper.py @@ -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: -- cgit v1.2.3