This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nneonneo
Recipients nneonneo
Date 2016-12-10.00:07:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481328446.9.0.450435696311.issue28927@psf.upfronthosting.co.za>
In-reply-to
Content
bytes.fromhex ignores space characters now (yay!) but still barfs if fed newlines or tabs:

>>> bytes.fromhex('ab\ncd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: non-hexadecimal number found in fromhex() arg at position 2
>>> bytes.fromhex('ab\tcd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: non-hexadecimal number found in fromhex() arg at position 2

It's often quite useful to paste blobs of hex into source code (or the REPL) and call ".fromhex" on them. These might include spaces, tabs and/or newlines, and barfing on these other whitespace characters is inconvenient.

I propose that bytes.fromhex should ignore all whitespace. A patch + test is attached.
History
Date User Action Args
2016-12-10 00:07:26nneonneosetrecipients: + nneonneo
2016-12-10 00:07:26nneonneosetmessageid: <1481328446.9.0.450435696311.issue28927@psf.upfronthosting.co.za>
2016-12-10 00:07:26nneonneolinkissue28927 messages
2016-12-10 00:07:26nneonneocreate