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 2E749429E26 for ; Fri, 22 Jul 2011 12:13:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.514 X-Spam-Level: X-Spam-Status: No, score=0.514 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, URI_HEX=1.313] 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 El13+PD7WJfz for ; Fri, 22 Jul 2011 12:13:25 -0700 (PDT) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 77ACB431FD0 for ; Fri, 22 Jul 2011 12:13:25 -0700 (PDT) Received: by wyh22 with SMTP id 22so1948891wyh.26 for ; Fri, 22 Jul 2011 12:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=d7dPS8VZgF/m4i/QF3aoQPNmtVGUeUEKl4HcZx4fmCo=; b=CcNrS0L/9A+tLyC6i+1+IVFC/SOfYfWfMyE8l63eAnokg3/ix7RNeWbAOTXYUTynbO DjOKZ3YLt0qBXAjqM/EAYl3B5kP+XEhfUZ3f9vyTv1hqA0KAZNIddvlu04yOub7BPqYi dfm3fj9yvoVtUYSKSqngNEmxJEQt9D9Ud4e8c= Received: by 10.216.60.144 with SMTP id u16mr2177039wec.5.1311362003243; Fri, 22 Jul 2011 12:13:23 -0700 (PDT) Received: from brick.lan (cpc1-sgyl2-0-0-cust47.sgyl.cable.virginmedia.com [80.192.18.48]) by mx.google.com with ESMTPS id o19sm2142134wbh.26.2011.07.22.12.13.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jul 2011 12:13:20 -0700 (PDT) Date: Fri, 22 Jul 2011 20:13:16 +0100 From: Patrick Totzke To: Michael Heinrich Subject: Re: [Patch] tag.py: Bugfix to avoid decode() on a NoneType object Message-ID: <20110722191316.GA12929@brick.lan> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: notmuch@notmuchmail.org 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: Fri, 22 Jul 2011 19:13:26 -0000 --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 probl= em: 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, >=20 > with current head I get following error in my python scripts when I read = the > tags of a message: >=20 > File "/home/heinrich/.local/lib/python2.6/site-packages/notmuch/tag.py"= , line > 88, in next > tag =3D Tags._get(self._tags).decode('utf-8') >=20 >=20 > Here is a patch: >=20 > diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag= =2Epy > 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 =3D Tags._get(self._tags).decode('utf-8') > + tag =3D Tags._get(self._tags) > if tag is None: > self._tags =3D None > raise StopIteration > + else: > + tag =3D tag.decode('utf-8') > nmlib.notmuch_tags_move_to_next(self._tags) > return tag > =20 >=20 > Michael. >=20 > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch --sm4nu43k4a2Rpi4c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk4py8wACgkQlDQDZ9fWxapwGwCfbczyKodcgJWrPsN6u6Chd4Y0 Q10AnR3VtSP3M2d9Gj75/0v00R2PgX/s =Qv7u -----END PGP SIGNATURE----- --sm4nu43k4a2Rpi4c--