summaryrefslogtreecommitdiffstats
path: root/Lib/hmac.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-03-03 02:59:49 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-03-03 02:59:49 (GMT)
commita351f7701a6d9e0648b4d108821ebd4ce7b38fee (patch)
tree4797bdff37569b8fbc6ab7722444592b6b248f55 /Lib/hmac.py
parent7f757edf15d130f82149c2133974056db1be201e (diff)
downloadcpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.zip
cpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.tar.gz
cpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.tar.bz2
Fixed failing unit tests due to str/bytes mismatch.
Changed "assert isinstance(...)" in hmac.py to raise proper TypeError.
Diffstat (limited to 'Lib/hmac.py')
-rw-r--r--Lib/hmac.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 6f2ae2e..0f59fd4 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -39,7 +39,8 @@ class HMAC:
if key is _secret_backdoor_key: # cheap
return
- assert isinstance(key, bytes), repr(key)
+ if not isinstance(key, bytes):
+ raise TypeError("expected bytes, but got %r" % type(key).__name__)
if digestmod is None:
import hashlib
@@ -84,7 +85,8 @@ class HMAC:
def update(self, msg):
"""Update this hashing object with the string msg.
"""
- assert isinstance(msg, bytes), repr(msg)
+ if not isinstance(msg, bytes):
+ raise TypeError("expected bytes, but got %r" % type(msg).__name__)
self.inner.update(msg)
def copy(self):