In Python 2.x I'm able to do this:
>>> '4f6c6567'.decode('hex_codec')
'Oleg'
But in Python 3.2 I encounter this error:
>>> b'4f6c6567'.decode('hex_codec')
Traceback (most recent call last):File "<pyshell#25>", line 1, in <module>b'4f6c6567'.decode('hex_codec')
TypeError: decoder did not return a str object (type=bytes)
According to the docs hex_codec
should provide "bytes-to-bytes mappings". So the object of byte-string is correctly used here.
How can I get rid of this error to be able to avoid unwieldy workarounds to convert from hex-encoded text?