# HG changeset patch # User Alexis S. L. Carvalho # Date 1182533574 10800 # Node ID a814a5b11fffb43c1b7d774422530509aa2212e8 # Parent de8ec7e1753abd09c3af64b9f7236f7fdede6f09 Work around urllib2 digest auth bug with Python < 2.5 This should fix issue570. diff -r de8ec7e1753a -r a814a5b11fff mercurial/httprepo.py --- a/mercurial/httprepo.py Thu Jun 21 23:42:06 2007 -0300 +++ b/mercurial/httprepo.py Fri Jun 22 14:32:54 2007 -0300 @@ -121,6 +121,20 @@ class httphandler(basehttphandler): pass +# In python < 2.5 AbstractDigestAuthHandler raises a ValueError if +# it doesn't know about the auth type requested. This can happen if +# somebody is using BasicAuth and types a bad password. +class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): + def http_error_auth_reqed(self, auth_header, host, req, headers): + try: + return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( + self, auth_header, host, req, headers) + except ValueError, inst: + arg = inst.args[0] + if arg.startswith("AbstractDigestAuthHandler doesn't know "): + return + raise + def zgenerator(f): zd = zlib.decompressobj() try: @@ -202,7 +216,7 @@ passmgr.add_password(None, host, user, passwd or '') handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), - urllib2.HTTPDigestAuthHandler(passmgr))) + httpdigestauthhandler(passmgr))) opener = urllib2.build_opener(*handlers) # 1.0 here is the _protocol_ version