1
0
Fork 0

Fix AttributeError: 'HTTPError' object has no attribute 'reason'

Not every version of urllib2 supplies a reason object on the
HTTPError exception that it throws from urlopen().  Work around
this by using str(e) instead and hope the string formatting includes
sufficient information.

Change-Id: I0f4586dba0aa7152691b2371627c951f91fdfc8d
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2011-10-11 09:31:58 -07:00
parent 29472463ba
commit bf1fbb20ab
2 changed files with 6 additions and 7 deletions

View file

@ -1491,7 +1491,7 @@ class Project(object):
msg = ''
raise DownloadError('HTTP %s%s' % (e.code, msg))
except urllib2.URLError, e:
raise DownloadError('%s (%s)' % (e.reason, req.get_host()))
raise DownloadError('%s: %s ' % (req.get_host(), str(e)))
p = None
try: