[PATCH 4/9] python: fix NotmuchError.__str__ if status == None

Justus Winter 4winter at informatik.uni-hamburg.de
Sun Sep 25 18:05:32 PDT 2011


Passing None to STATUS.status2str raises an ArgumentError. Add a
check for this case and provide a generic message.

Signed-off-by: Justus Winter <4winter at informatik.uni-hamburg.de>
---
 bindings/python/notmuch/globals.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
index dd0c858..8b73f91 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -97,8 +97,10 @@ class NotmuchError(Exception):
     def __str__(self):
         if self.message is not None:
             return self.message
-        else:
+        elif self.status is not None:
             return STATUS.status2str(self.status)
+        else:
+            return 'Unknown error'
 
 def _str(value):
     """Ensure a nicely utf-8 encoded string to pass to libnotmuch
-- 
1.7.6.3



More information about the notmuch mailing list