Message 191321 - Python tracker (original) (raw)
Problem: In hmac.py there's a type check that verifies that the msg parameter is of type bytes().
if not isinstance(msg, bytes): raise TypeError("expected bytes, but got %r" % type(msg).name)
That is incorrect. The hmac module should also work with other data types as long as they are supported by the underlying hashlib module, for example bytearray() and memoryview().
Suggestion: Remove that type check. hashlib will make sure str() and other invalid data types raises a TypeError.