Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 20223431FD0 for ; Wed, 13 Jul 2011 00:04:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8jVK-xAJ-v0b for ; Wed, 13 Jul 2011 00:04:51 -0700 (PDT) Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [85.10.199.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 1071C431FB6 for ; Wed, 13 Jul 2011 00:04:51 -0700 (PDT) Received: id: ukleinek by Chamillionaire.breakpoint.cc with local (easymta 1.00 BETA 1) id 1QgtV1-0003j4-Ch; Wed, 13 Jul 2011 09:04:47 +0200 Date: Wed, 13 Jul 2011 09:04:47 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Patrick Totzke Subject: Re: Encodings Message-ID: <20110713070447.GA14254@strlen.de> References: <87zkkkx6am.fsf@SSpaeth.de> <20110712212958.GA17348@brick.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110712212958.GA17348@brick.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Notmuch developer list X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2011 07:04:53 -0000 Hi Patrick, On Tue, Jul 12, 2011 at 10:29:58PM +0100, Patrick Totzke wrote: > I noticed that commit 687366b920caa5de6ea0b66b70cf2a11e5399f7b > breaks things with Database.get_all_tags: > > -------------------------------------->%------------------------------------- > AttributeError Traceback (most recent call last) > > /home/pazz/projects/alot/ in () > > /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. I think it would be right to enforce that tags are utf-8 encoded. Otherwise the users get strange results if they change their locale. Best regards Uwe