Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81743

Re: [Python-Dev] Unicode decode exception

Date 2014-11-30 21:33 -0700
From Michael Torrie <torriem@gmail.com>
Subject Re: [Python-Dev] Unicode decode exception
References <CAKcrOwft6+6TBCpcLoG8Z4fcbpjcECUmNd4Wu-NhRbHDwr1V-g@mail.gmail.com> <CAPTjJmqbUm8g0qszy-RamDQrDQgb1O3ievY+86dRJO=9Jr5weA@mail.gmail.com> <CAKcrOweVZ4-KUpW4a428zO_3_43-n5HA=YnXrAuFx3KyWkcmSA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16446.1417408427.18130.python-list@python.org> (permalink)

Show all headers | View raw


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).

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [Python-Dev] Unicode decode exception Michael Torrie <torriem@gmail.com> - 2014-11-30 21:33 -0700
  Re: [Python-Dev] Unicode decode exception wxjmfauth@gmail.com - 2014-12-01 23:28 -0800

csiph-web