X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fmessage.py;h=1b1f2174f4fcbeb2c6925becd41cabbceeba9b56;hb=54982e520c3bee74e947e311ee5b1219396fa1a8;hp=cce377d02a8024608bcf840252faae191d937acb;hpb=b10ce6bc23002d48916b1b2f375480e7540e3164;p=notmuch diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index cce377d0..1b1f2174 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -41,6 +41,7 @@ from .tag import Tags from .filenames import Filenames import email +import sys class Message(Python3StringMixIn): @@ -222,7 +223,7 @@ class Message(Python3StringMixIn): :returns: The header value as string :raises: :exc:`NotInitializedError` if the message is not initialized - :raises: :exc:`NullPointerError` if any error occured + :raises: :exc:`NullPointerError` if any error occurred """ if not self._msg: raise NotInitializedError() @@ -294,7 +295,7 @@ class Message(Python3StringMixIn): :returns: A :class:`Tags` iterator. :raises: :exc:`NotInitializedError` if the message is not initialized - :raises: :exc:`NullPointerError` if any error occured + :raises: :exc:`NullPointerError` if any error occurred """ if not self._msg: raise NotInitializedError() @@ -587,8 +588,11 @@ class Message(Python3StringMixIn): def get_message_parts(self): """Output like notmuch show""" - fp = open(self.get_filename()) - email_msg = email.message_from_file(fp) + fp = open(self.get_filename(), 'rb') + if sys.version_info[0] < 3: + email_msg = email.message_from_file(fp) + else: + email_msg = email.message_from_binary_file(fp) fp.close() out = []