From: Senthil Kumaran Date: Wed, 19 Oct 2011 18:50:13 +0000 (+0800) Subject: urllib.request - syntax changes enhancing readability. By Éric Araujo X-Git-Tag: v3.3.0a1~1129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a129c882cbe2f3b51babc047b08d9266634de2b;p=thirdparty%2FPython%2Fcpython.git urllib.request - syntax changes enhancing readability. By Éric Araujo --- 1a129c882cbe2f3b51babc047b08d9266634de2b diff --cc Lib/urllib/request.py index 65ce287588ff,8ea058fc6da6..71011bda7100 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@@ -830,20 -824,14 +829,20 @@@ class AbstractBasicAuthHandler self.retried += 1 if authreq: - mo = AbstractBasicAuthHandler.rx.search(authreq) - if mo: - scheme, quote, realm = mo.groups() - if scheme.lower() == 'basic': - response = self.retry_http_basic_auth(host, req, realm) - if response and response.code != 401: - self.retried = 0 - return response + scheme = authreq.split()[0] - if not scheme.lower() == 'basic': ++ if scheme.lower() != 'basic': + raise ValueError("AbstractBasicAuthHandler does not" + " support the following scheme: '%s'" % + scheme) + else: + mo = AbstractBasicAuthHandler.rx.search(authreq) + if mo: + scheme, quote, realm = mo.groups() + if scheme.lower() == 'basic': + response = self.retry_http_basic_auth(host, req, realm) + if response and response.code != 401: + self.retried = 0 + return response def retry_http_basic_auth(self, host, req, realm): user, pw = self.passwd.find_user_password(realm, host) @@@ -929,9 -917,6 +928,9 @@@ class AbstractDigestAuthHandler scheme = authreq.split()[0] if scheme.lower() == 'digest': return self.retry_http_digest_auth(req, authreq) - elif not scheme.lower() == 'basic': ++ elif scheme.lower() != 'basic': + raise ValueError("AbstractDigestAuthHandler does not support" + " the following scheme: '%s'" % scheme) def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1)