[Patch] tag.py: Bugfix to avoid decode() on a NoneType object

Michael Heinrich michael at haas-heinrich.de
Fri Jul 22 07:11:41 PDT 2011


Dear all,

with current head I get following error in my python scripts when I read the
tags of a message:

  File "/home/heinrich/.local/lib/python2.6/site-packages/notmuch/tag.py", line
88, in next
    tag = Tags._get(self._tags).decode('utf-8')


Here is a patch:

diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py
index 65a9118..e9049fc 100644
--- a/bindings/python/notmuch/tag.py
+++ b/bindings/python/notmuch/tag.py
@@ -85,10 +85,12 @@ class Tags(object):
             raise NotmuchError(STATUS.NOT_INITIALIZED)
         # No need to call nmlib.notmuch_tags_valid(self._tags);
         # Tags._get safely returns None, if there is no more valid tag.
-        tag = Tags._get(self._tags).decode('utf-8')
+        tag = Tags._get(self._tags)
         if tag is None:
             self._tags = None
             raise StopIteration
+        else:
+            tag = tag.decode('utf-8')
         nmlib.notmuch_tags_move_to_next(self._tags)
         return tag
 

Michael.



More information about the notmuch mailing list