X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fglobals.py;h=54a49b2d3f16895a8a8ce0b9ffc459b58a7cadf2;hb=50b0d0b8ade8aca7dd8434f638555c634b00ebe4;hp=f5c8d5288ea07edb249bd39dc99b9229cdd1db8e;hpb=4292b1197d8a43199c43164e9f8e764b3a809de4;p=notmuch diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py index f5c8d528..54a49b2d 100644 --- a/bindings/python/notmuch/globals.py +++ b/bindings/python/notmuch/globals.py @@ -18,7 +18,6 @@ Copyright 2010 Sebastian Spaeth ' """ 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 u"Operation on uninitialized object impossible." + return unicode(Status._status2str(status)) STATUS = Status(['SUCCESS', 'OUT_OF_MEMORY', @@ -135,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