X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fmessage.py;fp=bindings%2Fpython%2Fnotmuch%2Fmessage.py;h=d5b98e4fdfdf5ab19e41fcda61ce0fc57d7b301f;hp=cce377d02a8024608bcf840252faae191d937acb;hb=91fe20cd90ce46bf80c416a5c4451f76b4d69ec5;hpb=073188e6905f1b5a065f696c4d02d0d1b3a7d769 diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index cce377d0..d5b98e4f 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): @@ -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 = []