unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Patrick Totzke <patricktotzke@googlemail.com>
To: Sebastian Spaeth <Sebastian@SSpaeth.de>
Cc: Notmuch developer list <notmuch@notmuchmail.org>
Subject: Re: Encodings
Date: Tue, 12 Jul 2011 22:29:58 +0100	[thread overview]
Message-ID: <20110712212958.GA17348@brick.lan> (raw)
In-Reply-To: <87zkkkx6am.fsf@SSpaeth.de>

[-- Attachment #1: Type: text/plain, Size: 2094 bytes --]

Hiya,

I noticed that commit 687366b920caa5de6ea0b66b70cf2a11e5399f7b
breaks things with Database.get_all_tags:

-------------------------------------->%-------------------------------------
AttributeError                            Traceback (most recent call last)

/home/pazz/projects/alot/<ipython console> in <module>()

/usr/local/lib/python2.7/dist-packages/notmuch/tag.pyc in next(self)
     86         # No need to call nmlib.notmuch_tags_valid(self._tags);

     87         # Tags._get safely returns None, if there is no more valid tag.

---> 88         tag = Tags._get(self._tags).decode('utf-8')
     89         if tag is None:
     90             self._tags = None

AttributeError: 'NoneType' object has no attribute 'decode'
------------------------------------%<---------------------------------------

The reason is that the Tags.next() tries to decode before it tests if tag is None.
Now, we _could_ apply a patch like this one here:

---------------------------------->%-----------------------------------------
diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py
index 65a9118..2ae670d 100644
--- a/bindings/python/notmuch/tag.py
+++ b/bindings/python/notmuch/tag.py
@@ -85,12 +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
         nmlib.notmuch_tags_move_to_next(self._tags)
-        return tag
+        return tag.decode('utf-8')
 
     def __nonzero__(self):
         """Implement bool(Tags) check that can be repeatedly used
-------------------------------------------%<-----------------------------

But as Carl sais, we cannot guarantee that a tag is utf8 encoded anyway.
So i'd suggest we just revore the commit in question.
best,
/p

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  parent reply	other threads:[~2011-07-12 21:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 14:04 Encodings Sebastian Spaeth
2011-07-11 15:03 ` Encodings Carl Worth
2011-07-12 20:27   ` Encodings Patrick Totzke
2011-07-12 21:29 ` Patrick Totzke [this message]
2011-07-13  7:04   ` Encodings Uwe Kleine-König
2011-07-13  9:03     ` Encodings Patrick Totzke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110712212958.GA17348@brick.lan \
    --to=patricktotzke@googlemail.com \
    --cc=Sebastian@SSpaeth.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).