summaryrefslogtreecommitdiffstats
path: root/Lib/hmac.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-27 17:23:59 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-27 17:23:59 (GMT)
commit39478e852827a4ca6955151bf004c7a15099a4b1 (patch)
tree05e52988c7904b7c7dad9427411bece5f9c45fcb /Lib/hmac.py
parent85825dc1ff5cc21c5f3f453b30b825a7200609cb (diff)
downloadcpython-39478e852827a4ca6955151bf004c7a15099a4b1.zip
cpython-39478e852827a4ca6955151bf004c7a15099a4b1.tar.gz
cpython-39478e852827a4ca6955151bf004c7a15099a4b1.tar.bz2
Changes in anticipation of stricter str vs. bytes enforcement.
Diffstat (limited to 'Lib/hmac.py')
-rw-r--r--Lib/hmac.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 7bf3c03..1911689 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -37,10 +37,7 @@ class HMAC:
if key is _secret_backdoor_key: # cheap
return
- if not isinstance(key, bytes):
- if hasattr(key, "__index__"):
- raise TypeError("key can't be a number")
- key = bytes(key)
+ assert isinstance(key, bytes), repr(key)
if digestmod is None:
import hashlib
@@ -71,10 +68,7 @@ class HMAC:
def update(self, msg):
"""Update this hashing object with the string msg.
"""
- if not isinstance(msg, bytes):
- if hasattr(msg, "__index__"):
- raise TypeError("msg can't be a number")
- msg = bytes(msg)
+ assert isinstance(msg, bytes), repr(msg)
self.inner.update(msg)
def copy(self):