Changes in anticipation of stricter str vs. bytes enforcement.

This commit is contained in:
Guido van Rossum 2007-08-27 17:23:59 +00:00
parent 85825dc1ff
commit 39478e8528
15 changed files with 78 additions and 76 deletions

View file

@ -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):