aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings/python/notmuch/globals.py
diff options
context:
space:
mode:
authorGravatar Patrick Totzke <patricktotzke@gmail.com>2011-12-05 22:51:10 +0000
committerGravatar Sebastian Spaeth <Sebastian@SSpaeth.de>2011-12-06 13:27:08 +0100
commitffe3097e58220d96c7a18b1b6062330551378b82 (patch)
tree4fb9453f0643c2520ad71f8ba35eb030ff351b8b /bindings/python/notmuch/globals.py
parent2b0116119160f2dc8376a3570b23fd502328a521 (diff)
use __unicode__ for string representation
Diffstat (limited to 'bindings/python/notmuch/globals.py')
-rw-r--r--bindings/python/notmuch/globals.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
index f69c73d4..54a49b2d 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -48,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 u"Operation on uninitialized object impossible."
+ return unicode(Status._status2str(status))
STATUS = Status(['SUCCESS',
'OUT_OF_MEMORY',
@@ -134,12 +134,15 @@ 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:
return STATUS.status2str(self.status)
else:
- return 'Unknown error'
+ return u'Unknown error'
# List of Subclassed exceptions that correspond to STATUS values and are