Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general refactoring
authorW. Trevor King <wking@tremily.us>
Tue, 4 Feb 2014 19:14:53 +0000 (11:14 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:44 +0000 (09:59 -0800)
6b/0fd4053a758faa7177a3ea7a761f3b9de997ec [new file with mode: 0644]

diff --git a/6b/0fd4053a758faa7177a3ea7a761f3b9de997ec b/6b/0fd4053a758faa7177a3ea7a761f3b9de997ec
new file mode 100644 (file)
index 0000000..31b0476
--- /dev/null
@@ -0,0 +1,195 @@
+Return-Path: <wking@tremily.us>\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 511DD431FBD\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Feb 2014 11:15:02 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_DNSWL_NONE=-0.0001] 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 JO79NcFFFMcn for <notmuch@notmuchmail.org>;\r
+       Tue,  4 Feb 2014 11:14:56 -0800 (PST)\r
+Received: from qmta07.westchester.pa.mail.comcast.net\r
+       (qmta07.westchester.pa.mail.comcast.net [76.96.62.64])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3B56C431FBC\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Feb 2014 11:14:56 -0800 (PST)\r
+Received: from omta15.westchester.pa.mail.comcast.net ([76.96.62.87])\r
+       by qmta07.westchester.pa.mail.comcast.net with comcast\r
+       id NEvm1n0061swQuc57KEv6T; Tue, 04 Feb 2014 19:14:55 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by omta15.westchester.pa.mail.comcast.net with comcast\r
+       id NKEu1n00D152l3L3bKEu7Q; Tue, 04 Feb 2014 19:14:55 +0000\r
+Received: by odin.tremily.us (Postfix, from userid 1000)\r
+       id A69BEFCF3BF; Tue,  4 Feb 2014 11:14:53 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;\r
+       t=1391541293; bh=teo73fKl9lcjS3Vb2MBIhj/ic7aYnmhEU1fGWCm2BGg=;\r
+       h=Date:From:To:Cc:Subject:References:In-Reply-To;\r
+       b=lDdSoAXBH65QYVoaYdsIY4h8p3TIBodFnkyNh/ewgXW0DOQSMTTzrrgI/3o/Mglhc\r
+       +p9qwKxiDKlPD7cdwB7MOcqHij4PmVmiMCLAL/CL+nRoCEdc7ADviF90gRygCHNo4n\r
+       mwMhJHlQBDVSBINBRzSScO45vlNVups29t9W+sJ4=\r
+Date: Tue, 4 Feb 2014 11:14:53 -0800\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>\r
+Subject: Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general\r
+       refactoring\r
+Message-ID: <20140204191453.GV14197@odin.tremily.us>\r
+References: <cover.1391424512.git.wking@tremily.us>\r
+       <m2ha8frjgg.fsf@guru.guru-group.fi>\r
+       <20140204005331.GQ14197@odin.tremily.us>\r
+       <m2fvnzp3uh.fsf@guru.guru-group.fi>\r
+       <20140204161142.GS14197@odin.tremily.us>\r
+       <m2a9e6zppp.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha1;\r
+       protocol="application/pgp-signature"; boundary="zD4kWSsXNMryRTZe"\r
+Content-Disposition: inline\r
+In-Reply-To: <m2a9e6zppp.fsf@guru.guru-group.fi>\r
+OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8;\r
+       url=http://tremily.us/pubkey.txt\r
+User-Agent: Mutt/1.5.22 (2013-10-16)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+       s=q20121106; t=1391541295;\r
+       bh=qgEIttGAOUL7mjviI7bfVbSGUdx/aC+Ofh/r1bXhBJs=;\r
+       h=Received:Received:Received:Date:From:To:Subject:Message-ID:\r
+       MIME-Version:Content-Type;\r
+       b=R8dEWjoQHwgIcEpoJSOuN+lQTqSHTVJOXDYgbZD4p3exkhQuspZWIkyJhkxizGN9C\r
+       Fzodb1F9jdGDIh36XqmazhcgoSzW7G167dqq6vrHxfOkL1AzI2ml/H1SjGe0yASoCE\r
+       oMNa3iNH/JdvTQ3lIzJSixUmZB+zKbIorOXgFJzG1Oy2doxO/KGzQm9GJvWTqjTqyN\r
+       PSMUp8/Uv2DJSJoV9zJFkqMirP1uqeq5wz2BK0DWPzDbEHoNS5rM8AZ05YNJYgco5h\r
+       hBxDzXM7BPXh8b421KjCt1pL9TTZ0Af763fnI6bf5D8lw+FftJXAjydn0HhO8BuPsQ\r
+       CU+WdeTDTcffg==\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: Tue, 04 Feb 2014 19:15:02 -0000\r
+\r
+\r
+--zD4kWSsXNMryRTZe\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On Tue, Feb 04, 2014 at 08:40:18PM +0200, Tomi Ollila wrote:\r
+> On Tue, Feb 04 2014, W. Trevor King wrote:\r
+> >\r
+> >   >>> from __future__ import unicode_literals\r
+> >   >>> import codecs\r
+> >   >>> import locale\r
+> >   >>> import sys\r
+> >   >>> print(locale.getpreferredencoding())  # same as yours\r
+> >   UTF-8\r
+> >   >>> print(sys.getdefaultencoding())  # same as yours\r
+> >   ascii\r
+> >   >>> _ENCODING =3D locale.getpreferredencoding() or sys.getdefaultenco=\r
+ding()\r
+> >   >>> print(_ENCODING)  # double-check default encodings\r
+> >   UTF-8\r
+> >   >>> byte_stream =3D sys.stdout  # copied from Page.write\r
+> >   >>> stream =3D codecs.getwriter(encoding=3D_ENCODING)(stream=3Dbyte_s=\r
+tream)\r
+> >   >>> data =3D {'from': '\u017b'}  # fake the troublesome data\r
+> >   >>> print(type(data['from']))  # double-check unicode_literals\r
+> >   <type 'unicode'>\r
+> >   >>> string =3D '  <td>{from}</td>\n'.format(**data)\r
+> >   >>> stream.write(string)\r
+> >     <td>=C5=BB</td>\r
+> >\r
+> > It looks like you'll have the same _ENCODING as I do (UTF-8).  That\r
+> > means your stream should be wrapped in a UTF-8 StreamWriter, so I\r
+> > don't understand why it's converting to ASCII.  Can you run through\r
+> > the above on your troublesome machine and confirm that stream.write()\r
+> > is still raising the exception?  If it doesn't work, can you just\r
+> > paste that whole run in your next email?\r
+>=20\r
+> I don't know what to paste, so i paste this:\r
+>=20\r
+> $ python\r
+> Python 2.6.6 (r266:84292, Nov 21 2013, 12:39:37)=20\r
+> [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2\r
+> Type "help", "copyright", "credits" or "license" for more information.\r
+\r
+It looks like you left out:\r
+\r
+  from __future__ import unicode_literals\r
+\r
+Can you try again with that line as the first command?\r
+\r
+> >>> data =3D {'from': '\u017b'}\r
+> >>> print(type(data['from']))=20\r
+> <type 'str'>\r
+\r
+which is why your data is a 'str' and not a 'unicode' instance.\r
+\r
+> >>> string =3D '  <td>{from}</td>\n'.format(**data)\r
+> >>> print string\r
+>   <td>\u017b</td>\r
+>=20\r
+> and then:\r
+>=20\r
+> >>> data =3D {'from': u'\u017b'}\r
+\r
+This works around the lack of unicode_literals with an explicit u''.\r
+\r
+> >>> print(type(data['from']))=20\r
+> <type 'unicode'>\r
+> >>> string =3D '  <td>{from}</td>\n'.format(**data)\r
+> Traceback (most recent call last):\r
+>   File "<stdin>", line 1, in <module>\r
+> UnicodeEncodeError: 'ascii' codec can't encode character u'\u017b' in\r
+\r
+However, without unicode_literals or an explicit u'', you're format\r
+string '=E2=80=A6{from}' is a str (it should be a 'unicode' instance with\r
+unicode_literals).\r
+\r
+> >>> import os\r
+> >>> print os.environ['LANG']\r
+> en_US.UTF-8\r
+\r
+That's good anyway ;).  Thanks for digging into this :).\r
+\r
+Cheers,\r
+Trevor\r
+\r
+--=20\r
+This email may be signed or encrypted with GnuPG (http://www.gnupg.org).\r
+For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\r
+\r
+--zD4kWSsXNMryRTZe\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: OpenPGP digital signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2.0.22 (GNU/Linux)\r
+\r
+iQIcBAEBAgAGBQJS8TwsAAoJEKKfehoaNkbtRPAP/i/PtIT6gMW14hkLuPy1BksK\r
+m7TuPzNokEAE0+RVQF2OIFrK3VboowMgQZICL70ZUIYZmp3vSyJv4m9SWH2N2gw9\r
+0USZhga1OYUmS3eUucFjfuCK5dVXYOxUtRvXoUZh3AgHjV0V6bIu0QpTCJghEKSG\r
+Z5k4Bway4dV/CjNFQsHFzqpsw3W93+eOWQdi6ddV0v2yzSc7h8eVlB/i2DHcvSXX\r
+VjHwPnKVt8UnEWUf9MyYGrSDzUfJrmr60ux4ntTykHNvlDV7gX2I1yHtx/K/iwks\r
+n31fARQmM3F7r3sAkM4IWHT/+bjRfD+k5S2EnQDdNadR1T0etO/+ybrFZwTB8nmV\r
+gwdHdOylsJcqiFl9y2tbplVTdxnAKy8y1di2zxYCEGNL4BhWv2ak8wFz9dMkAs9W\r
+hUI6Q0GcCR0E9BWksts6FJYP+ZgoFv4tKrozW++5VVy0gExQPv8bF4wOngCnibqk\r
+Ir7Ec6K88N4Az320xdTzQZR+nr9i272f5Aa4XOOFfEJpZQrH1eIe5Eiu0jymraen\r
+SybaBMGDlAy4D4c7FXJ6XlPWolUH1nw8fVq3eoDq5qN5/b6F05cb8ouP1vG2q8fn\r
+dg2QllsAD6GB001nzxCMo5JlwBdTw/l78f2aujeK7L6toWSWWBfgKNfddZWq6CKu\r
+o52ndagLxMGPpKoY15og\r
+=gPZZ\r
+-----END PGP SIGNATURE-----\r
+\r
+--zD4kWSsXNMryRTZe--\r