]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/tag.py
python: fix error handling
[notmuch] / bindings / python / notmuch / tag.py
index f3a3d27e501dbfb5886ef4031f99490ff1a36968..4881db9fa2cdae0220f0f28398e14b69c334b7c1 100644 (file)
@@ -70,7 +70,7 @@ class Tags(object):
         :TODO: Make the iterator optionally work more than once by
                cache the tags in the Python object(?)
         """
-        if tags_p is None:
+        if not tags_p:
             raise NotmuchError(STATUS.NULL_POINTER)
 
         self._tags = tags_p
@@ -111,13 +111,17 @@ class Tags(object):
         return self._valid(self._tags) > 0
 
     def __str__(self):
-        """The str() representation of Tags() is a space separated list of tags
+        return unicode(self).encode('utf-8')
 
-        .. note:: As this iterates over the tags, we will not be able
-               to iterate over them again (as in retrieve them)! If
-               the tags have been exhausted already, this will raise a
-               :exc:`NotmuchError` STATUS.NOT_INITIALIZED on
-               subsequent attempts.
+    def __unicode__(self):
+        """string representation of :class:`Tags`: a space separated list of tags
+
+        .. note::
+
+            As this iterates over the tags, we will not be able to iterate over
+            them again (as in retrieve them)! If the tags have been exhausted
+            already, this will raise a :exc:`NotmuchError`
+            STATUS.NOT_INITIALIZED on subsequent attempts.
         """
         return " ".join(self)