Commit a4add31c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix unicode issues with hex encoding

parent 928a16ad
......@@ -31,6 +31,7 @@ import math
import operator
import logging
import traceback
import codecs
from inspect import currentframe, getframeinfo
import binascii
from textwrap import dedent
......@@ -2380,7 +2381,9 @@ def primary(root, context):
prim.value = "''"
elif root.text[-1] in ('H', 'h'):
prim.value = "'{}'".format(root.text[1:-2].decode('hex'))
hexstring = codecs.decode(root.text[1:-2], 'hex') # -> bytes
hexstring = hexstring.decode('utf-8') # -> string
prim.value = ("'{}'".format(hexstring))
except (ValueError, TypeError) as err:
(root, 'Octet string literal: {}'.format(err)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment