Re: [Patch] tag.py: Bugfix to avoid decode() on a NoneType object
authorPatrick Totzke <patricktotzke@googlemail.com>
Fri, 22 Jul 2011 19:13:16 +0000 (20:13 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:12 +0000 (09:39 -0800)
a7/bdc20fe2a1005c789dc5c98aba56c5ea5b6bdd [new file with mode: 0644]

diff --git a/a7/bdc20fe2a1005c789dc5c98aba56c5ea5b6bdd b/a7/bdc20fe2a1005c789dc5c98aba56c5ea5b6bdd
new file mode 100644 (file)
index 0000000..8d84920
--- /dev/null
@@ -0,0 +1,144 @@
+Return-Path: <patricktotzke@googlemail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2E749429E26\r
+       for <notmuch@notmuchmail.org>; Fri, 22 Jul 2011 12:13:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.514\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.514 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, URI_HEX=1.313]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id El13+PD7WJfz for <notmuch@notmuchmail.org>;\r
+       Fri, 22 Jul 2011 12:13:25 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 77ACB431FD0\r
+       for <notmuch@notmuchmail.org>; Fri, 22 Jul 2011 12:13:25 -0700 (PDT)\r
+Received: by wyh22 with SMTP id 22so1948891wyh.26\r
+       for <notmuch@notmuchmail.org>; Fri, 22 Jul 2011 12:13:24 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=googlemail.com; s=gamma;\r
+       h=date:from:to:cc:subject:message-id:references:mime-version\r
+       :content-type:content-disposition:in-reply-to:user-agent;\r
+       bh=d7dPS8VZgF/m4i/QF3aoQPNmtVGUeUEKl4HcZx4fmCo=;\r
+       b=CcNrS0L/9A+tLyC6i+1+IVFC/SOfYfWfMyE8l63eAnokg3/ix7RNeWbAOTXYUTynbO\r
+       DjOKZ3YLt0qBXAjqM/EAYl3B5kP+XEhfUZ3f9vyTv1hqA0KAZNIddvlu04yOub7BPqYi\r
+       dfm3fj9yvoVtUYSKSqngNEmxJEQt9D9Ud4e8c=\r
+Received: by 10.216.60.144 with SMTP id u16mr2177039wec.5.1311362003243;\r
+       Fri, 22 Jul 2011 12:13:23 -0700 (PDT)\r
+Received: from brick.lan (cpc1-sgyl2-0-0-cust47.sgyl.cable.virginmedia.com\r
+       [80.192.18.48])\r
+       by mx.google.com with ESMTPS id o19sm2142134wbh.26.2011.07.22.12.13.19\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 22 Jul 2011 12:13:20 -0700 (PDT)\r
+Date: Fri, 22 Jul 2011 20:13:16 +0100\r
+From: Patrick Totzke <patricktotzke@googlemail.com>\r
+To: Michael Heinrich <michael@haas-heinrich.de>\r
+Subject: Re: [Patch] tag.py: Bugfix to avoid decode() on a NoneType object\r
+Message-ID: <20110722191316.GA12929@brick.lan>\r
+References: <loom.20110722T160702-94@post.gmane.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha1;\r
+       protocol="application/pgp-signature"; boundary="sm4nu43k4a2Rpi4c"\r
+Content-Disposition: inline\r
+In-Reply-To: <loom.20110722T160702-94@post.gmane.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 22 Jul 2011 19:13:26 -0000\r
+\r
+\r
+--sm4nu43k4a2Rpi4c\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Hi Michael,\r
+\r
+I also fell over this a while ago. (cf. http://notmuch.198994.n3.nabble.com=\r
+/Encodings-td3159281.html)\r
+Your patch certainly fix the immediate error, but there is ore to the probl=\r
+em:\r
+Tagstrings seem to be the only ones stored by notmuch as-is, so unlike\r
+headers, they don't get converted to utf-8. The patch that lead to\r
+this .decode('utf-8') was pushed a bit too hastily.\r
+As Uwe mentiones in above cited thread, we could consider enforcing\r
+tags to be utf-8..\r
+\r
+best,\r
+/p\r
+\r
+\r
+On Fri, Jul 22, 2011 at 02:11:41PM +0000, Michael Heinrich wrote:\r
+> Dear all,\r
+>=20\r
+> with current head I get following error in my python scripts when I read =\r
+the\r
+> tags of a message:\r
+>=20\r
+>   File "/home/heinrich/.local/lib/python2.6/site-packages/notmuch/tag.py"=\r
+, line\r
+> 88, in next\r
+>     tag =3D Tags._get(self._tags).decode('utf-8')\r
+>=20\r
+>=20\r
+> Here is a patch:\r
+>=20\r
+> diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag=\r
+=2Epy\r
+> index 65a9118..e9049fc 100644\r
+> --- a/bindings/python/notmuch/tag.py\r
+> +++ b/bindings/python/notmuch/tag.py\r
+> @@ -85,10 +85,12 @@ class Tags(object):\r
+>              raise NotmuchError(STATUS.NOT_INITIALIZED)\r
+>          # No need to call nmlib.notmuch_tags_valid(self._tags);\r
+>          # Tags._get safely returns None, if there is no more valid tag.\r
+> -        tag =3D Tags._get(self._tags).decode('utf-8')\r
+> +        tag =3D Tags._get(self._tags)\r
+>          if tag is None:\r
+>              self._tags =3D None\r
+>              raise StopIteration\r
+> +        else:\r
+> +            tag =3D tag.decode('utf-8')\r
+>          nmlib.notmuch_tags_move_to_next(self._tags)\r
+>          return tag\r
+> =20\r
+>=20\r
+> Michael.\r
+>=20\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--sm4nu43k4a2Rpi4c\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: Digital signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.11 (GNU/Linux)\r
+\r
+iEYEARECAAYFAk4py8wACgkQlDQDZ9fWxapwGwCfbczyKodcgJWrPsN6u6Chd4Y0\r
+Q10AnR3VtSP3M2d9Gj75/0v00R2PgX/s\r
+=Qv7u\r
+-----END PGP SIGNATURE-----\r
+\r
+--sm4nu43k4a2Rpi4c--\r