X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fglobals.py;h=54a49b2d3f16895a8a8ce0b9ffc459b58a7cadf2;hp=f69c73d4cfe5985e5d8920fbd8a759a5d23451b8;hb=4ed0362d41e62d5254be6cfb46e0c0c9fd9de0a0;hpb=86b0aeb1ca0f12286e13b71d7f025ba8a59a808d 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