diff options
-rw-r--r-- | Lib/hmac.py | 2 | ||||
-rw-r--r-- | Lib/test/test_hmac.py | 12 | ||||
-rw-r--r-- | Misc/ACKS | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/Lib/hmac.py b/Lib/hmac.py index 9c080233da..4297a7171a 100644 --- a/Lib/hmac.py +++ b/Lib/hmac.py @@ -35,7 +35,7 @@ class HMAC: """ if not isinstance(key, bytes): - raise TypeError("expected bytes, but got %r" % type(key).__name__) + raise TypeError("key: expected bytes, but got %r" % type(key).__name__) if digestmod is None: import hashlib diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py index 11cacb4d03..4ca7cec44c 100644 --- a/Lib/test/test_hmac.py +++ b/Lib/test/test_hmac.py @@ -234,6 +234,18 @@ class ConstructorTestCase(unittest.TestCase): except: self.fail("Standard constructor call raised exception.") + def test_with_str_key(self): + # Pass a key of type str, which is an error, because it expects a key + # of type bytes + with self.assertRaises(TypeError): + h = hmac.HMAC("key") + + def test_dot_new_with_str_key(self): + # Pass a key of type str, which is an error, because it expects a key + # of type bytes + with self.assertRaises(TypeError): + h = hmac.new("key") + def test_withtext(self): # Constructor call with text. try: @@ -13,6 +13,7 @@ and the list is in rough alphabetical order by last names. Rajiv Abraham David Abrahams +Marc Abramowitz Ron Adam Ali Afshar Jim Ahlstrom |