mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
Fix error message when using notmuch_status_to_string
The python exception class was incorrectly loading the error message which resulted in unprintable exception objects.
This commit is contained in:
parent
d7f9572413
commit
ca4e1d885b
2 changed files with 10 additions and 1 deletions
|
@ -83,7 +83,8 @@ class NotmuchError(Exception):
|
||||||
if self.message:
|
if self.message:
|
||||||
return self.message
|
return self.message
|
||||||
elif self.status:
|
elif self.status:
|
||||||
return capi.lib.notmuch_status_to_string(self.status)
|
char_str = capi.lib.notmuch_status_to_string(self.status)
|
||||||
|
return capi.ffi.string(char_str).decode(errors='replace')
|
||||||
else:
|
else:
|
||||||
return 'Unknown error'
|
return 'Unknown error'
|
||||||
|
|
||||||
|
|
8
bindings/python-cffi/tests/test_errors.py
Normal file
8
bindings/python-cffi/tests/test_errors.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from notmuch2 import _capi as capi
|
||||||
|
from notmuch2 import _errors as errors
|
||||||
|
|
||||||
|
def test_status_no_message():
|
||||||
|
exc = errors.NotmuchError(capi.lib.NOTMUCH_STATUS_PATH_ERROR)
|
||||||
|
assert exc.status == capi.lib.NOTMUCH_STATUS_PATH_ERROR
|
||||||
|
assert exc.message is None
|
||||||
|
assert str(exc) == 'Path supplied is illegal for this function'
|
Loading…
Reference in a new issue