We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
assignee = 'https://github.com/tiran'
closed_at = <Date 2013-07-01.11:09:50.812>
created_at = <Date 2013-06-17.10:38:28.690>
labels = ['type-feature', 'library']
title = 'hmac unnecessarily restricts input to "bytes"'
updated_at = <Date 2013-11-12.08:43:07.457>
user = 'https://bugs.python.org/jborgstrom'
activity = <Date 2013-11-12.08:43:07.457>
actor = 'mpb'
assignee = 'christian.heimes'
closed = True
closed_date = <Date 2013-07-01.11:09:50.812>
closer = 'christian.heimes'
components = ['Library (Lib)']
creation = <Date 2013-06-17.10:38:28.690>
creator = 'jborgstrom'
dependencies = 
files = ['30628', '30637']
hgrepos = 
issue_num = 18240
keywords = ['patch']
message_count = 10.0
messages = ['191321', '191324', '191374', '191395', '191396', '191398', '191399', '191757', '192120', '192121']
nosy_count = 5.0
nosy_names = ['gregory.p.smith', 'christian.heimes', 'python-dev', 'jborgstrom', 'mpb']
pr_nums = 
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue18240'
versions = ['Python 3.4']
The text was updated successfully, but these errors were encountered:
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().
Remove that type check. hashlib will make sure str() and other invalid data types raises a TypeError.
Sorry, something went wrong.
We can also lift the restriction for key a bit. It can also take a bytearray as argument. bytearray has translate() and supports bytes + bytearay.
Thanks for your patch! Please add tests for the new feature. The documentation needs versionchanged tags, too.
Patch updated to include tests and versionchanged tags
Thanks for your update.
As far as I can tell you haven't signed our contributor agreement yet. Can you please do so?
Of course. I've now signed and filed the agreement.
It may take a day or two until your signature makes it through red tape. I'll get back to you. :)
Your account hasn't been flagged yet. I'm going to ping the person in charge.
New changeset 636947fe131e by Christian Heimes in branch 'default':
bpo-18240: The HMAC module is no longer restricted to bytes and accepts
Your CLA came through and I have applied your patch. Thank you very much for your contribution!
No branches or pull requests