UnicodeDecodeError with python API

W. Trevor King wking at tremily.us
Sun Mar 29 09:36:58 PDT 2015


On Sun, Mar 29, 2015 at 09:08:28AM -0400, Sebastian Fischmeister wrote:
> Traceback (most recent call last):
>   File "./test.py", line 66, in <module>
>     print(type(y.get_part(1)))
>>   File "/usr/lib/python3.4/email/parser.py", line 54, in parse
>     data = fp.read(8192)
>   File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
>     return codecs.ascii_decode(input, self.errors)[0]
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3447: ordinal not in range(128)

My first guess is that the file's encoding doesn't match your locale.
Do you have a non-ASCII locale set?  You can check with:

  $ locale
  LANG=en_US.UTF-8
  LC_CTYPE="en_US.UTF-8"
  LC_NUMERIC="en_US.UTF-8"
  LC_TIME="en_US.UTF-8"
  LC_COLLATE=C
  LC_MONETARY="en_US.UTF-8"
  LC_MESSAGES="en_US.UTF-8"
  LC_PAPER="en_US.UTF-8"
  LC_NAME="en_US.UTF-8"
  LC_ADDRESS="en_US.UTF-8"
  LC_TELEPHONE="en_US.UTF-8"
  LC_MEASUREMENT="en_US.UTF-8"
  LC_IDENTIFICATION="en_US.UTF-8"
  LC_ALL=

Although you can obviously have a different preferred language or
Unicode-capable encoding.  What you don't want is:

  # locale
  LANG=
  LC_CTYPE="POSIX"
  LC_NUMERIC="POSIX"
  LC_TIME="POSIX"
  LC_COLLATE="POSIX"
  LC_MONETARY="POSIX"
  LC_MESSAGES="POSIX"
  LC_PAPER="POSIX"
  LC_NAME="POSIX"
  LC_ADDRESS="POSIX"
  LC_TELEPHONE="POSIX"
  LC_MEASUREMENT="POSIX"
  LC_IDENTIFICATION="POSIX"
  LC_ALL=

If that's not the problem, could you attach the troublesome message?
Or a minimal example derived from the troublesome message?

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20150329/45fe6e5c/attachment.pgp>


More information about the notmuch mailing list