[Python-Dev] Unicode decode exception

Michael Torrie torriem at gmail.com
Sun Nov 30 23:33:28 EST 2014


On 11/30/2014 09:19 PM, balaji marisetti wrote:
> The default encoding is "UTF-8". It works if I do:
> 
> with open("filename", errors="ignore") as f:
>     ....
> 
> So I think Python2, by default, ignores all errors whereas Python3 doesn't

Do you mean that the file is supposed to be utf-8 but isn't?  Because if
it is, you need to tell open about it in Python3 to make sure that's the
decoding scheme it uses. Otherwise you will see this decode error.

Also I'm not sure you posted the full traceback. Usually a
UnicodeDecodeError says something about an invalid byte while using a
specific unicode decoding scheme (say, ASCII, which can't handle utf-8
bytes).



More information about the Python-list mailing list