1 Return-Path: <wking@tremily.us>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 511DD431FBD
\r
6 for <notmuch@notmuchmail.org>; Tue, 4 Feb 2014 11:15:02 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id JO79NcFFFMcn for <notmuch@notmuchmail.org>;
\r
17 Tue, 4 Feb 2014 11:14:56 -0800 (PST)
\r
18 Received: from qmta07.westchester.pa.mail.comcast.net
\r
19 (qmta07.westchester.pa.mail.comcast.net [76.96.62.64])
\r
20 by olra.theworths.org (Postfix) with ESMTP id 3B56C431FBC
\r
21 for <notmuch@notmuchmail.org>; Tue, 4 Feb 2014 11:14:56 -0800 (PST)
\r
22 Received: from omta15.westchester.pa.mail.comcast.net ([76.96.62.87])
\r
23 by qmta07.westchester.pa.mail.comcast.net with comcast
\r
24 id NEvm1n0061swQuc57KEv6T; Tue, 04 Feb 2014 19:14:55 +0000
\r
25 Received: from odin.tremily.us ([24.18.63.50])
\r
26 by omta15.westchester.pa.mail.comcast.net with comcast
\r
27 id NKEu1n00D152l3L3bKEu7Q; Tue, 04 Feb 2014 19:14:55 +0000
\r
28 Received: by odin.tremily.us (Postfix, from userid 1000)
\r
29 id A69BEFCF3BF; Tue, 4 Feb 2014 11:14:53 -0800 (PST)
\r
30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;
\r
31 t=1391541293; bh=teo73fKl9lcjS3Vb2MBIhj/ic7aYnmhEU1fGWCm2BGg=;
\r
32 h=Date:From:To:Cc:Subject:References:In-Reply-To;
\r
33 b=lDdSoAXBH65QYVoaYdsIY4h8p3TIBodFnkyNh/ewgXW0DOQSMTTzrrgI/3o/Mglhc
\r
34 +p9qwKxiDKlPD7cdwB7MOcqHij4PmVmiMCLAL/CL+nRoCEdc7ADviF90gRygCHNo4n
\r
35 mwMhJHlQBDVSBINBRzSScO45vlNVups29t9W+sJ4=
\r
36 Date: Tue, 4 Feb 2014 11:14:53 -0800
\r
37 From: "W. Trevor King" <wking@tremily.us>
\r
38 To: Tomi Ollila <tomi.ollila@iki.fi>
\r
39 Subject: Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general
\r
41 Message-ID: <20140204191453.GV14197@odin.tremily.us>
\r
42 References: <cover.1391424512.git.wking@tremily.us>
\r
43 <m2ha8frjgg.fsf@guru.guru-group.fi>
\r
44 <20140204005331.GQ14197@odin.tremily.us>
\r
45 <m2fvnzp3uh.fsf@guru.guru-group.fi>
\r
46 <20140204161142.GS14197@odin.tremily.us>
\r
47 <m2a9e6zppp.fsf@guru.guru-group.fi>
\r
49 Content-Type: multipart/signed; micalg=pgp-sha1;
\r
50 protocol="application/pgp-signature"; boundary="zD4kWSsXNMryRTZe"
\r
51 Content-Disposition: inline
\r
52 In-Reply-To: <m2a9e6zppp.fsf@guru.guru-group.fi>
\r
53 OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8;
\r
54 url=http://tremily.us/pubkey.txt
\r
55 User-Agent: Mutt/1.5.22 (2013-10-16)
\r
56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;
\r
57 s=q20121106; t=1391541295;
\r
58 bh=qgEIttGAOUL7mjviI7bfVbSGUdx/aC+Ofh/r1bXhBJs=;
\r
59 h=Received:Received:Received:Date:From:To:Subject:Message-ID:
\r
60 MIME-Version:Content-Type;
\r
61 b=R8dEWjoQHwgIcEpoJSOuN+lQTqSHTVJOXDYgbZD4p3exkhQuspZWIkyJhkxizGN9C
\r
62 Fzodb1F9jdGDIh36XqmazhcgoSzW7G167dqq6vrHxfOkL1AzI2ml/H1SjGe0yASoCE
\r
63 oMNa3iNH/JdvTQ3lIzJSixUmZB+zKbIorOXgFJzG1Oy2doxO/KGzQm9GJvWTqjTqyN
\r
64 PSMUp8/Uv2DJSJoV9zJFkqMirP1uqeq5wz2BK0DWPzDbEHoNS5rM8AZ05YNJYgco5h
\r
65 hBxDzXM7BPXh8b421KjCt1pL9TTZ0Af763fnI6bf5D8lw+FftJXAjydn0HhO8BuPsQ
\r
67 Cc: notmuch@notmuchmail.org
\r
68 X-BeenThere: notmuch@notmuchmail.org
\r
69 X-Mailman-Version: 2.1.13
\r
71 List-Id: "Use and development of the notmuch mail system."
\r
72 <notmuch.notmuchmail.org>
\r
73 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
75 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
76 List-Post: <mailto:notmuch@notmuchmail.org>
\r
77 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
78 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
79 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
80 X-List-Received-Date: Tue, 04 Feb 2014 19:15:02 -0000
\r
84 Content-Type: text/plain; charset=utf-8
\r
85 Content-Disposition: inline
\r
86 Content-Transfer-Encoding: quoted-printable
\r
88 On Tue, Feb 04, 2014 at 08:40:18PM +0200, Tomi Ollila wrote:
\r
89 > On Tue, Feb 04 2014, W. Trevor King wrote:
\r
91 > > >>> from __future__ import unicode_literals
\r
92 > > >>> import codecs
\r
93 > > >>> import locale
\r
95 > > >>> print(locale.getpreferredencoding()) # same as yours
\r
97 > > >>> print(sys.getdefaultencoding()) # same as yours
\r
99 > > >>> _ENCODING =3D locale.getpreferredencoding() or sys.getdefaultenco=
\r
101 > > >>> print(_ENCODING) # double-check default encodings
\r
103 > > >>> byte_stream =3D sys.stdout # copied from Page.write
\r
104 > > >>> stream =3D codecs.getwriter(encoding=3D_ENCODING)(stream=3Dbyte_s=
\r
106 > > >>> data =3D {'from': '\u017b'} # fake the troublesome data
\r
107 > > >>> print(type(data['from'])) # double-check unicode_literals
\r
108 > > <type 'unicode'>
\r
109 > > >>> string =3D ' <td>{from}</td>\n'.format(**data)
\r
110 > > >>> stream.write(string)
\r
111 > > <td>=C5=BB</td>
\r
113 > > It looks like you'll have the same _ENCODING as I do (UTF-8). That
\r
114 > > means your stream should be wrapped in a UTF-8 StreamWriter, so I
\r
115 > > don't understand why it's converting to ASCII. Can you run through
\r
116 > > the above on your troublesome machine and confirm that stream.write()
\r
117 > > is still raising the exception? If it doesn't work, can you just
\r
118 > > paste that whole run in your next email?
\r
120 > I don't know what to paste, so i paste this:
\r
123 > Python 2.6.6 (r266:84292, Nov 21 2013, 12:39:37)=20
\r
124 > [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
\r
125 > Type "help", "copyright", "credits" or "license" for more information.
\r
127 It looks like you left out:
\r
129 from __future__ import unicode_literals
\r
131 Can you try again with that line as the first command?
\r
133 > >>> data =3D {'from': '\u017b'}
\r
134 > >>> print(type(data['from']))=20
\r
137 which is why your data is a 'str' and not a 'unicode' instance.
\r
139 > >>> string =3D ' <td>{from}</td>\n'.format(**data)
\r
145 > >>> data =3D {'from': u'\u017b'}
\r
147 This works around the lack of unicode_literals with an explicit u''.
\r
149 > >>> print(type(data['from']))=20
\r
151 > >>> string =3D ' <td>{from}</td>\n'.format(**data)
\r
152 > Traceback (most recent call last):
\r
153 > File "<stdin>", line 1, in <module>
\r
154 > UnicodeEncodeError: 'ascii' codec can't encode character u'\u017b' in
\r
156 However, without unicode_literals or an explicit u'', you're format
\r
157 string '=E2=80=A6{from}' is a str (it should be a 'unicode' instance with
\r
161 > >>> print os.environ['LANG']
\r
164 That's good anyway ;). Thanks for digging into this :).
\r
170 This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
\r
171 For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
\r
174 Content-Type: application/pgp-signature; name="signature.asc"
\r
175 Content-Description: OpenPGP digital signature
\r
177 -----BEGIN PGP SIGNATURE-----
\r
178 Version: GnuPG v2.0.22 (GNU/Linux)
\r
180 iQIcBAEBAgAGBQJS8TwsAAoJEKKfehoaNkbtRPAP/i/PtIT6gMW14hkLuPy1BksK
\r
181 m7TuPzNokEAE0+RVQF2OIFrK3VboowMgQZICL70ZUIYZmp3vSyJv4m9SWH2N2gw9
\r
182 0USZhga1OYUmS3eUucFjfuCK5dVXYOxUtRvXoUZh3AgHjV0V6bIu0QpTCJghEKSG
\r
183 Z5k4Bway4dV/CjNFQsHFzqpsw3W93+eOWQdi6ddV0v2yzSc7h8eVlB/i2DHcvSXX
\r
184 VjHwPnKVt8UnEWUf9MyYGrSDzUfJrmr60ux4ntTykHNvlDV7gX2I1yHtx/K/iwks
\r
185 n31fARQmM3F7r3sAkM4IWHT/+bjRfD+k5S2EnQDdNadR1T0etO/+ybrFZwTB8nmV
\r
186 gwdHdOylsJcqiFl9y2tbplVTdxnAKy8y1di2zxYCEGNL4BhWv2ak8wFz9dMkAs9W
\r
187 hUI6Q0GcCR0E9BWksts6FJYP+ZgoFv4tKrozW++5VVy0gExQPv8bF4wOngCnibqk
\r
188 Ir7Ec6K88N4Az320xdTzQZR+nr9i272f5Aa4XOOFfEJpZQrH1eIe5Eiu0jymraen
\r
189 SybaBMGDlAy4D4c7FXJ6XlPWolUH1nw8fVq3eoDq5qN5/b6F05cb8ouP1vG2q8fn
\r
190 dg2QllsAD6GB001nzxCMo5JlwBdTw/l78f2aujeK7L6toWSWWBfgKNfddZWq6CKu
\r
191 o52ndagLxMGPpKoY15og
\r
193 -----END PGP SIGNATURE-----
\r
195 --zD4kWSsXNMryRTZe--
\r