summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2_localnet.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-29 14:26:52 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-29 14:26:52 (GMT)
commit813601486216e197069a1e2d119ea00202426bcd (patch)
treec7afb1c6abc3f30b6f3d204ed565cf272e90e9b8 /Lib/test/test_urllib2_localnet.py
parentec9a4afa32e723bece8b77fe79b2371cd4947270 (diff)
downloadcpython-813601486216e197069a1e2d119ea00202426bcd.zip
cpython-813601486216e197069a1e2d119ea00202426bcd.tar.gz
cpython-813601486216e197069a1e2d119ea00202426bcd.tar.bz2
Fix up brokenness with hashing, now hashlib is strict in requiring bytes too.
Diffstat (limited to 'Lib/test/test_urllib2_localnet.py')
-rw-r--r--Lib/test/test_urllib2_localnet.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index 8784f95..dde9504 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -88,7 +88,7 @@ class DigestAuthHandler:
def _generate_nonce(self):
self._request_num += 1
- nonce = hashlib.md5(str(self._request_num)).hexdigest()
+ nonce = hashlib.md5(str(self._request_num).encode("ascii")).hexdigest()
self._nonces.append(nonce)
return nonce
@@ -116,14 +116,14 @@ class DigestAuthHandler:
final_dict["method"] = method
final_dict["uri"] = uri
HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict
- HA1 = hashlib.md5(HA1_str).hexdigest()
+ HA1 = hashlib.md5(HA1_str.encode("ascii")).hexdigest()
HA2_str = "%(method)s:%(uri)s" % final_dict
- HA2 = hashlib.md5(HA2_str).hexdigest()
+ HA2 = hashlib.md5(HA2_str.encode("ascii")).hexdigest()
final_dict["HA1"] = HA1
final_dict["HA2"] = HA2
response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \
"%(cnonce)s:%(qop)s:%(HA2)s" % final_dict
- response = hashlib.md5(response_str).hexdigest()
+ response = hashlib.md5(response_str.encode("ascii")).hexdigest()
return response == auth_dict["response"]