In legacy code the original exception gets caught in the variable exc
:
File "/usr/lib64/python2.7/urllib2.py", line 1177, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 32] Datenübergabe unterbrochen (broken pipe)>
I want to use unicode(exc)
but this fails:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31:
ordinal not in range(128)
How can I create a unicode string from the exception exc
?
Environment: Python 2.7