raise a BrowserIncorrectPassword exception when handling a 401
This commit is contained in:
parent
e2edfe3d8f
commit
8677d8b183
1 changed files with 8 additions and 4 deletions
|
|
@ -260,11 +260,15 @@ class StandardBrowser(mechanize.Browser):
|
|||
return self._openurl(*args, **kwargs)
|
||||
|
||||
def get_exception(self, e):
|
||||
if (isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode') and e.getcode() in (404, 403)) or \
|
||||
isinstance(e, mechanize.BrowserStateError):
|
||||
if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode'):
|
||||
if e.getcode() in (404, 403):
|
||||
return BrowserHTTPNotFound
|
||||
if e.getcode() == 401:
|
||||
return BrowserIncorrectPassword
|
||||
elif isinstance(e, mechanize.BrowserStateError):
|
||||
return BrowserHTTPNotFound
|
||||
else:
|
||||
return BrowserHTTPError
|
||||
|
||||
return BrowserHTTPError
|
||||
|
||||
def readurl(self, url, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue