]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/globals.py
py3k: All strings are unicode strings in py3k
[notmuch] / bindings / python / notmuch / globals.py
index f5c8d5288ea07edb249bd39dc99b9229cdd1db8e..99e6a10d1b38e7d43766ff9ba41e5249ce53ab5c 100644 (file)
@@ -18,7 +18,6 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'
 """
 
 from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
-from ctypes.util import find_library
 
 #-----------------------------------------------------------------------------
 #package-global instance of the notmuch library
@@ -49,11 +48,11 @@ class Status(Enum):
 
     @classmethod
     def status2str(self, status):
-        """Get a string representation of a notmuch_status_t value."""
+        """Get a (unicode) string representation of a notmuch_status_t value."""
         # define strings for custom error messages
         if status == STATUS.NOT_INITIALIZED:
             return "Operation on uninitialized object impossible."
-        return str(Status._status2str(status))
+        return unicode(Status._status2str(status))
 
 STATUS = Status(['SUCCESS',
   'OUT_OF_MEMORY',
@@ -135,6 +134,9 @@ class NotmuchError(Exception):
         self.message = message
 
     def __str__(self):
+        return unicode(self).encode('utf-8')
+
+    def __unicode__(self):
         if self.message is not None:
             return self.message
         elif self.status is not None: