check exception attribute (closes #581)

This commit is contained in:
Romain Bignon 2011-05-08 13:55:15 +02:00
commit cb1478f455

View file

@ -293,7 +293,7 @@ class BaseBrowser(mechanize.Browser):
return mechanize.Browser.open(self, *args, **kwargs)
def get_exception(self, e):
if isinstance(e, urllib2.HTTPError) and e.getcode() == 404:
if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode') and e.getcode() == 404:
return BrowserHTTPNotFound
else:
return BrowserHTTPError