unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] python: fix get_property error when property doesn't exist
@ 2019-01-27  8:40 Vincent A
  2019-02-01 13:45 ` David Bremner
  2019-02-21 11:23 ` David Bremner
  0 siblings, 2 replies; 6+ messages in thread
From: Vincent A @ 2019-01-27  8:40 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

In Python bindings, Message.get_property fails with an AttributeError 
when trying to fetch a property that doesn't exist.

[-- Attachment #2: 0001-python-fix-get_property-error-when-property-doesn-t-.patch --]
[-- Type: text/x-patch, Size: 972 bytes --]

From d712832ba982085975c27b23bb502af82e638b39 Mon Sep 17 00:00:00 2001
From: hydrargyrum <dev@indigo.re>
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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-21 11:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-27  8:40 [PATCH] python: fix get_property error when property doesn't exist Vincent A
2019-02-01 13:45 ` David Bremner
2019-02-06 19:24   ` VA
2019-02-17 11:19     ` David Bremner
2019-02-18 19:29       ` Tomi Ollila
2019-02-21 11:23 ` David Bremner

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).