catch UnicodeDecodeError

Stefan Behnel stefan_ml at
Thu Jul 26 14:24:40 CEST 2012

Philipp Hagemeister, 26.07.2012 14:17:
> On 07/26/2012 01:15 PM, Stefan Behnel wrote:
>>> exits with a UnicodeDecodeError.
>> ... that tells you the exact code line where the error occurred.
> Which property of a UnicodeDecodeError does include that information?
> On cPython 2.7 and 3.2, I see only start and end, both of which refer to
> the number of bytes read so far.

Read again: "*code* line". The OP was apparently failing to see that the
error did not originate in the source code lines that he had wrapped with a
try-except statement but somewhere else, thus leading to the misguided
impression that the exception was not properly caught by the except clause.


More information about the Python-list mailing list