From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id EA02E6DE01E6 for ; Sun, 27 Jan 2019 00:49:36 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -2.301 X-Spam-Level: X-Spam-Status: No, score=-2.301 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SDfWWLE0gNE4 for ; Sun, 27 Jan 2019 00:49:36 -0800 (PST) X-Greylist: delayed 546 seconds by postgrey-1.36 at arlo; Sun, 27 Jan 2019 00:49:35 PST Received: from smtp-sh2.infomaniak.ch (smtp-sh2.infomaniak.ch [128.65.195.6]) by arlo.cworth.org (Postfix) with ESMTPS id 9AF9A6DE01E1 for ; Sun, 27 Jan 2019 00:49:35 -0800 (PST) Received: from smtp8.infomaniak.ch (smtp8.infomaniak.ch [83.166.132.38]) by smtp-sh.infomaniak.ch (8.14.5/8.14.5) with ESMTP id x0R8eLvj026947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 27 Jan 2019 09:40:23 +0100 Received: from [IPv6:2a01:e35:8be3:1490:22cf:30ff:fe9a:43cf] ([IPv6:2a01:e35:8be3:1490:22cf:30ff:fe9a:43cf]) (authenticated bits=0) by smtp8.infomaniak.ch (8.14.5/8.14.5) with ESMTP id x0R8eH1l074615 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Sun, 27 Jan 2019 09:40:20 +0100 To: notmuch@notmuchmail.org From: Vincent A Subject: [PATCH] python: fix get_property error when property doesn't exist Message-ID: Date: Sun, 27 Jan 2019 09:40:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------EE6B9981CD56DD0F1AE8127C" Content-Language: fr X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 X-Mailman-Approved-At: Wed, 30 Jan 2019 10:56:42 -0800 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jan 2019 08:49:37 -0000 This is a multi-part message in MIME format. --------------EE6B9981CD56DD0F1AE8127C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit In Python bindings, Message.get_property fails with an AttributeError when trying to fetch a property that doesn't exist. --------------EE6B9981CD56DD0F1AE8127C Content-Type: text/x-patch; name="0001-python-fix-get_property-error-when-property-doesn-t-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-python-fix-get_property-error-when-property-doesn-t-.pa"; filename*1="tch" >From d712832ba982085975c27b23bb502af82e638b39 Mon Sep 17 00:00:00 2001 From: hydrargyrum Date: Sun, 6 Jan 2019 16:08:55 +0100 Subject: [PATCH] python: fix get_property error when property doesn't exist --- bindings/python/notmuch/message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index de0fb415..6e32b5f7 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -482,7 +482,9 @@ class Message(Python3StringMixIn): if status != 0: raise NotmuchError(status) - return value.value.decode('utf-8') if value is not None else None + if value is None or value.value is None: + return None + return value.value.decode('utf-8') def get_properties(self, prop="", exact=False): """ Get the properties of the message, returning a generator of -- 2.20.1 --------------EE6B9981CD56DD0F1AE8127C--