Issue #28992: Use bytes.fromhex().

This commit is contained in:
Serhiy Storchaka 2016-12-21 12:59:28 +02:00
parent 47bdc40352
commit 8cbd3df3ce
4 changed files with 7 additions and 10 deletions

View file

@ -574,7 +574,7 @@ def unquote_to_bytes(string):
# if the function is never called
global _hextobyte
if _hextobyte is None:
_hextobyte = {(a + b).encode(): bytes([int(a + b, 16)])
_hextobyte = {(a + b).encode(): bytes.fromhex(a + b)
for a in _hexdig for b in _hexdig}
for item in bits[1:]:
try: