[Patch] tag.py: Bugfix to avoid decode() on a NoneType object
Patrick Totzke
patricktotzke at googlemail.com
Fri Jul 22 12:13:16 PDT 2011
Hi Michael,
I also fell over this a while ago. (cf. http://notmuch.198994.n3.nabble.com/Encodings-td3159281.html)
Your patch certainly fix the immediate error, but there is ore to the problem:
Tagstrings seem to be the only ones stored by notmuch as-is, so unlike
headers, they don't get converted to utf-8. The patch that lead to
this .decode('utf-8') was pushed a bit too hastily.
As Uwe mentiones in above cited thread, we could consider enforcing
tags to be utf-8..
best,
/p
On Fri, Jul 22, 2011 at 02:11:41PM +0000, Michael Heinrich wrote:
> Dear all,
>
> with current head I get following error in my python scripts when I read the
> tags of a message:
>
> File "/home/heinrich/.local/lib/python2.6/site-packages/notmuch/tag.py", line
> 88, in next
> tag = Tags._get(self._tags).decode('utf-8')
>
>
> Here is a patch:
>
> diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py
> index 65a9118..e9049fc 100644
> --- a/bindings/python/notmuch/tag.py
> +++ b/bindings/python/notmuch/tag.py
> @@ -85,10 +85,12 @@ class Tags(object):
> raise NotmuchError(STATUS.NOT_INITIALIZED)
> # No need to call nmlib.notmuch_tags_valid(self._tags);
> # Tags._get safely returns None, if there is no more valid tag.
> - tag = Tags._get(self._tags).decode('utf-8')
> + tag = Tags._get(self._tags)
> if tag is None:
> self._tags = None
> raise StopIteration
> + else:
> + tag = tag.decode('utf-8')
> nmlib.notmuch_tags_move_to_next(self._tags)
> return tag
>
>
> Michael.
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110722/15d9e35b/attachment.pgp>
More information about the notmuch
mailing list