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,10 +260,14 @@ class StandardBrowser(mechanize.Browser):
|
||||||
return self._openurl(*args, **kwargs)
|
return self._openurl(*args, **kwargs)
|
||||||
|
|
||||||
def get_exception(self, e):
|
def get_exception(self, e):
|
||||||
if (isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode') and e.getcode() in (404, 403)) or \
|
if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode'):
|
||||||
isinstance(e, mechanize.BrowserStateError):
|
if e.getcode() in (404, 403):
|
||||||
return BrowserHTTPNotFound
|
return BrowserHTTPNotFound
|
||||||
else:
|
if e.getcode() == 401:
|
||||||
|
return BrowserIncorrectPassword
|
||||||
|
elif isinstance(e, mechanize.BrowserStateError):
|
||||||
|
return BrowserHTTPNotFound
|
||||||
|
|
||||||
return BrowserHTTPError
|
return BrowserHTTPError
|
||||||
|
|
||||||
def readurl(self, url, *args, **kwargs):
|
def readurl(self, url, *args, **kwargs):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue