[New-bugs-announce] [issue18240] hmac unnecessarily restricts input to "bytes"

Jonas Borgström report at bugs.python.org
Mon Jun 17 12:38:28 CEST 2013


New submission from Jonas Borgström:

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.

----------
components: Library (Lib)
messages: 191321
nosy: jborg
priority: normal
severity: normal
status: open
title: hmac unnecessarily restricts input to "bytes"
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18240>
_______________________________________


More information about the New-bugs-announce mailing list