From: Kenneth Reitz Date: Mon, 23 Jan 2012 05:25:48 +0000 (-0500) Subject: blah X-Git-Tag: v0.10.1~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9cae98c167316993b134fa8a937acd7c90fa2953;p=services%2Fpython-requests.git blah --- diff --git a/requests/auth.py b/requests/auth.py index 61ea850..974e8bb 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -78,9 +78,17 @@ class HTTPDigestAuth(AuthBase): algorithm = algorithm.upper() # lambdas assume digest modules are imported at the top level if algorithm == 'MD5': - H = lambda x: hashlib.md5(x).hexdigest() + def h(x): + if isinstance(x, str): + x = x.encode('utf-8') + return hashlib.md5(x).hexdigest() + H = h elif algorithm == 'SHA': - H = lambda x: hashlib.sha1(x).hexdigest() + def h(x): + if isinstance(x, str): + x = x.encode('utf-8') + return hashlib.sha1(x).hexdigest() + H = h # XXX MD5-sess KD = lambda s, d: H("%s:%s" % (s, d))