[New-bugs-announce] [issue28927] bytes.fromhex should ignore all whitespace
Robert Xiao
report at bugs.python.org
Fri Dec 9 19:07:26 EST 2016
New submission from Robert Xiao:
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.
----------
files: fromhex.patch
keywords: patch
messages: 282811
nosy: nneonneo
priority: normal
severity: normal
status: open
title: bytes.fromhex should ignore all whitespace
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file45823/fromhex.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28927>
_______________________________________
More information about the New-bugs-announce
mailing list