From: "W. Trevor King" <wking@tremily.us>
To: Sebastian Fischmeister <sfischme@uwaterloo.ca>
Cc: notmuch <notmuch@notmuchmail.org>
Subject: Re: UnicodeDecodeError with python API
Date: Sun, 29 Mar 2015 09:36:58 -0700 [thread overview]
Message-ID: <20150329163658.GK22036@odin.tremily.us> (raw)
In-Reply-To: <874mp4q7e7.fsf@uwaterloo.ca>
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-03-29 16:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-29 13:08 UnicodeDecodeError with python API Sebastian Fischmeister
2015-03-29 16:36 ` W. Trevor King [this message]
2015-03-29 23:10 ` Sebastian Fischmeister
2015-03-30 5:26 ` W. Trevor King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150329163658.GK22036@odin.tremily.us \
--to=wking@tremily.us \
--cc=notmuch@notmuchmail.org \
--cc=sfischme@uwaterloo.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).