1 Return-Path: <patricktotzke@googlemail.com>
\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 1BECA429E26
\r
6 for <notmuch@notmuchmail.org>; Tue, 12 Jul 2011 13:27:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 0yk8njA5LMDJ for <notmuch@notmuchmail.org>;
\r
17 Tue, 12 Jul 2011 13:27:40 -0700 (PDT)
\r
18 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com
\r
19 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 66347431FB6
\r
22 for <notmuch@notmuchmail.org>; Tue, 12 Jul 2011 13:27:40 -0700 (PDT)
\r
23 Received: by wyh22 with SMTP id 22so3950968wyh.26
\r
24 for <notmuch@notmuchmail.org>; Tue, 12 Jul 2011 13:27:39 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=googlemail.com; s=gamma;
\r
27 h=date:from:to:cc:subject:message-id:references:mime-version
\r
28 :content-type:content-disposition:in-reply-to:user-agent;
\r
29 bh=IxBDl5UgD2x2/A9IzqOxtoO3sKtRrB5nUoUZD3+JJA8=;
\r
30 b=eGNE6kQnF/TlPTYTLVMZsC1PUqppZ4PFoedCyvHBvKTXGxLjnDHo/EmxjC3nHFZaEh
\r
31 qn9cKDQjKq+gK8bwf8l+K9+ZtGg+KbpzJZyGIIWcKeE55q25wNMZhwm+aVy6EvCn0Wbo
\r
32 aGOxpnXlpwcwlMyhmfmPQwLYRRYrTCaE4kS4s=
\r
33 Received: by 10.227.199.82 with SMTP id er18mr295154wbb.63.1310502457671;
\r
34 Tue, 12 Jul 2011 13:27:37 -0700 (PDT)
\r
35 Received: from brick.lan (cpc1-sgyl2-0-0-cust47.sgyl.cable.virginmedia.com
\r
37 by mx.google.com with ESMTPS id ex2sm11128623wbb.31.2011.07.12.13.27.34
\r
38 (version=TLSv1/SSLv3 cipher=OTHER);
\r
39 Tue, 12 Jul 2011 13:27:35 -0700 (PDT)
\r
40 Date: Tue, 12 Jul 2011 21:27:31 +0100
\r
41 From: Patrick Totzke <patricktotzke@googlemail.com>
\r
42 To: Carl Worth <cworth@cworth.org>
\r
43 Subject: Re: Encodings
\r
44 Message-ID: <20110712202731.GA28929@brick.lan>
\r
45 References: <87zkkkx6am.fsf@SSpaeth.de> <87box0lv05.fsf@yoom.home.cworth.org>
\r
47 Content-Type: multipart/signed; micalg=pgp-sha1;
\r
48 protocol="application/pgp-signature"; boundary="JYK4vJDZwFMowpUq"
\r
49 Content-Disposition: inline
\r
50 In-Reply-To: <87box0lv05.fsf@yoom.home.cworth.org>
\r
51 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
52 Cc: Notmuch developer list <notmuch@notmuchmail.org>
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Tue, 12 Jul 2011 20:27:42 -0000
\r
69 Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR"
\r
70 Content-Disposition: inline
\r
74 Content-Type: text/plain; charset=us-ascii
\r
75 Content-Disposition: inline
\r
76 Content-Transfer-Encoding: quoted-printable
\r
80 As discussed on irc, if notmuch stores header values in utf8,
\r
81 its safe to decode them to unicode instances here.
\r
86 On Mon, Jul 11, 2011 at 08:03:38AM -0700, Carl Worth wrote:
\r
87 > On Mon, 11 Jul 2011 16:04:17 +0200, Sebastian Spaeth <Sebastian@SSpaeth.d=
\r
89 > > The answer is that things are very implicit. notmuch.h speaks of
\r
90 > > strings but never mentions encodings
\r
92 > Much of this was intentional on my part.
\r
94 > For example, I intentionally avoided restrictions on what could be
\r
95 > stored as a tag in the database, (other than the terminating character
\r
96 > implied by "string" of course).
\r
98 > > So, can be document what encoding we are expected to pass in the various
\r
101 > Yes, let's clarify documentation wherever we need to.
\r
103 > > For some of the stuff we read directly from the files, eg
\r
104 > > arbitrary headers, we can probably be least sure
\r
106 > The headers should be decoded to utf-8, (via
\r
107 > g_mime_utils_header_decode_text), before being stored in the database.
\r
109 > > but are e.g. the returned tags always utf-8?
\r
111 > No. The tag data is returned exactly as the user presented it.
\r
113 > > I would love to make the python bindings use unicode() instances in
\r
114 > > cases where we can be sure to actually receive utf-8 encoded strings.
\r
116 > > Encodings make my brain hurt. Unfortunately one cannot simply ignore
\r
119 > I think a lot of the pain here is due to some bad design decisions in
\r
120 > python itself. Of course, my saying that doesn't make things any easier
\r
123 > But do tell me what more we can do to clarify behavior or documentation.
\r
128 > carl.d.worth@intel.com
\r
132 > _______________________________________________
\r
133 > notmuch mailing list
\r
134 > notmuch@notmuchmail.org
\r
135 > http://notmuchmail.org/mailman/listinfo/notmuch
\r
139 Content-Type: text/x-diff; charset=us-ascii
\r
140 Content-Disposition: attachment; filename="0001-unicode-return-value-for-Message.get_header.patch"
\r
141 Content-Transfer-Encoding: quoted-printable
\r
143 =46rom 988a9832d714dfa0f91b2b1185a50acb4a6ca4b5 Mon Sep 17 00:00:00 2001
\r
144 =46rom: pazz <patricktotzke@gmail.com>
\r
145 Date: Tue, 12 Jul 2011 19:47:39 +0100
\r
146 Subject: [PATCH 1/8] unicode return value for Message.get_header()
\r
148 As discussed in IRC, notmuch recodes mailheaders to
\r
149 utf-8, so we can safely decode them into unicode instances.
\r
151 bindings/python/notmuch/message.py | 8 +++++---
\r
152 1 files changed, 5 insertions(+), 3 deletions(-)
\r
154 diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/m=
\r
156 index 763d2c6..4a43a88 100644
\r
157 --- a/bindings/python/notmuch/message.py
\r
158 +++ b/bindings/python/notmuch/message.py
\r
159 @@ -379,14 +379,16 @@ class Message(object):
\r
161 :param header: The name of the header to be retrieved.
\r
162 It is not case-sensitive (TODO: confirm).
\r
163 - :type header: str
\r
164 - :returns: The header value as string
\r
165 + :type header: str or unicode instance
\r
166 + :returns: The header value as a unicode string
\r
167 :exception: :exc:`NotmuchError`
\r
169 * STATUS.NOT_INITIALIZED if the message=20
\r
170 is not initialized.
\r
171 * STATUS.NULL_POINTER, if no header was found
\r
173 + if isinstance(header, unicode):
\r
174 + header =3D header.encode('utf-8')
\r
175 if self._msg is None:
\r
176 raise NotmuchError(STATUS.NOT_INITIALIZED)
\r
178 @@ -394,7 +396,7 @@ class Message(object):
\r
179 header =3D Message._get_header (self._msg, header)
\r
180 if header =3D=3D None:
\r
181 raise NotmuchError(STATUS.NULL_POINTER)
\r
183 + return header.decode('utf-8')
\r
185 def get_filename(self):
\r
186 """Returns the file path of the message file
\r
191 --T4sUOijqQbZv57TR--
\r
194 Content-Type: application/pgp-signature; name="signature.asc"
\r
195 Content-Description: Digital signature
\r
197 -----BEGIN PGP SIGNATURE-----
\r
198 Version: GnuPG v1.4.11 (GNU/Linux)
\r
200 iEYEARECAAYFAk4crjMACgkQlDQDZ9fWxarMuQCgjRjhtJGBfVZJIEA4M1f1tS7o
\r
201 5mEAn1Yp9YhNPIo5N6GZWNiZ53xlyKC2
\r
203 -----END PGP SIGNATURE-----
\r
205 --JYK4vJDZwFMowpUq--
\r