notmuch/bindings/python
Florian Klink 91fe20cd90 python: open messages in binary mode
currently, notmuch's get_message_parts() opens the file in text mode and passes
the file object to email.message_from_file(fp). In case the email contains
UTF-8 characters, reading might fail inside email.parser with the following exception:

  File "/usr/lib/python3.6/site-packages/notmuch/message.py", line 591, in get_message_parts
    email_msg = email.message_from_binary_file(fp)
  File "/usr/lib/python3.6/email/__init__.py", line 62, in message_from_binary_file
    return BytesParser(*args, **kws).parse(fp)
  File "/usr/lib/python3.6/email/parser.py", line 110, in parse
    return self.parser.parse(fp, headersonly)
  File "/usr/lib/python3.6/email/parser.py", line 54, in parse
    data = fp.read(8192)
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 1865: invalid continuation byte

To fix this, read file in binary mode and pass to
email.message_from_binary_file(fp).

Unfortunately, Python 2 doesn't support
email.message_from_binary_file(fp), so keep using
email.message_from_file(fp) there.

Signed-off-by: Florian Klink <flokli@flokli.de>
2017-10-02 07:21:33 -03:00
..
debian Move everything down into a bindings/python directory. 2010-04-21 17:29:34 -07:00
docs database: add n_d_index_file (deprecates n_d_add_message) 2017-08-23 07:38:37 -03:00
notmuch python: open messages in binary mode 2017-10-02 07:21:33 -03:00
.gitignore Use rooted paths in .gitignore files 2017-08-18 19:42:35 -03:00
MANIFEST.in Move everything down into a bindings/python directory. 2010-04-21 17:29:34 -07:00
README fix typo 2017-08-18 19:47:40 -03:00
setup.py Use https instead of http where possible 2016-06-05 08:32:17 -03:00

notmuch -- The python interface to notmuch
==========================================

This module makes the functionality of the notmuch library
(`https://notmuchmail.org`_) available to python. Successful import of
this module depends on a libnotmuch.so|dll being available on the
user's system.

If you have downloaded the full source tarball, you can create the
documentation with sphinx installed, go to the docs directory and
"make html". A static version of the documentation is available at:

  https://notmuch.readthedocs.io/projects/notmuch-python/

To build the python bindings, do

  python setup.py install --prefix=path/to/your/preferred/location