1 Return-Path: <Sebastian@SSpaeth.de>
\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 1466D431FD0
\r
6 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 02:43:55 -0700 (PDT)
\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 zpXitqDt5i6r for <notmuch@notmuchmail.org>;
\r
17 Mon, 11 Jul 2011 02:43:53 -0700 (PDT)
\r
18 Received: from homiemail-a22.g.dreamhost.com (caiajhbdcbef.dreamhost.com
\r
20 by olra.theworths.org (Postfix) with ESMTP id 73870431FB6
\r
21 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 02:43:53 -0700 (PDT)
\r
22 Received: from homiemail-a22.g.dreamhost.com (localhost [127.0.0.1])
\r
23 by homiemail-a22.g.dreamhost.com (Postfix) with ESMTP id AE0DC1A8069;
\r
24 Mon, 11 Jul 2011 02:43:52 -0700 (PDT)
\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=SSpaeth.de; h=from:to:cc:subject
\r
26 :date:message-id:in-reply-to:references; q=dns; s=sspaeth.de; b=
\r
27 K/n2e98f+orXTCp0Kaom7QX5nvYvbgbkexESWwl6P7RTGbkndGhFG2Z+GFRETQtq
\r
28 FvvDW6cdFPuZKnyk8MeivPHPpgH4DF4WD1bPNDLWXSCZ8wvqe7njJTeYSKbvvqD3
\r
29 e3vISGXiFfgzMEsnygcn7FJL0bNXuCVo04BUzLPDpa0=
\r
30 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=SSpaeth.de; h=from:to:cc
\r
31 :subject:date:message-id:in-reply-to:references; s=sspaeth.de;
\r
32 bh=gJRCICozrqH3qylzFf+5CpmhyVI=; b=jaeEt/ZbdKL9ZpwEQI6XwZxPkPKH
\r
33 FNGB94s1IMZmg4fszsEvBbYXmlICbv8f984yiQBf1n+OPbM0YL9/UHop4kiTSW7Z
\r
34 T3yMFRDWGGDonRhKAKAw+ALDd8XaIB/9rIq7QzY+oQU4SXJxQY1Sq8UFKLgbd4Zv
\r
36 Received: from spaetzbook.sspaeth.de (mtec-hg-docking-1-dhcp-253.ethz.ch
\r
38 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
39 (No client certificate requested)
\r
40 (Authenticated sender: fax@sspaeth.de)
\r
41 by homiemail-a22.g.dreamhost.com (Postfix) with ESMTPSA id 098541A8061;
\r
42 Mon, 11 Jul 2011 02:43:50 -0700 (PDT)
\r
43 Received: by spaetzbook.sspaeth.de (sSMTP sendmail emulation);
\r
44 Mon, 11 Jul 2011 11:43:49 +0200
\r
45 From: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
46 To: notmuch@notmuchmail.org
\r
47 Subject: [PATCH] python: Encode query string as a utf-8 byte array
\r
48 Date: Mon, 11 Jul 2011 11:43:47 +0200
\r
49 Message-Id: <1310377427-7656-1-git-send-email-Sebastian@SSpaeth.de>
\r
50 X-Mailer: git-send-email 1.7.4.1
\r
51 In-Reply-To: <20110707113700.GA16347@megatron>
\r
52 References: <20110707113700.GA16347@megatron>
\r
53 Cc: Patrick Totzke <patricktotzke@googlemail.com>
\r
54 X-BeenThere: notmuch@notmuchmail.org
\r
55 X-Mailman-Version: 2.1.13
\r
57 List-Id: "Use and development of the notmuch mail system."
\r
58 <notmuch.notmuchmail.org>
\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
62 List-Post: <mailto:notmuch@notmuchmail.org>
\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
66 X-List-Received-Date: Mon, 11 Jul 2011 09:43:55 -0000
\r
68 If we pass in an unicode instance as query string, we would probably get
\r
69 weird behavior (and indeed do so, see mail
\r
70 id:"20110707113700.GA16347@megatron"). If a unicode instance is passed
\r
71 in, make sure we encode it properly to an utf-8 encoded byte string.
\r
73 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
75 Patrick, can you test, if this fixes the inconsistent behavior in a good way?
\r
77 bindings/python/notmuch/database.py | 8 +++++---
\r
78 1 files changed, 5 insertions(+), 3 deletions(-)
\r
80 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
\r
81 index 3770b13..859fb18 100644
\r
82 --- a/bindings/python/notmuch/database.py
\r
83 +++ b/bindings/python/notmuch/database.py
\r
84 @@ -501,7 +501,7 @@ class Query(object):
\r
85 :param db: An open database which we derive the Query from.
\r
86 :type db: :class:`Database`
\r
87 :param querystr: The query string for the message.
\r
88 - :type querystr: str
\r
89 + :type querystr: utf-8 encoded str or unicode
\r
93 @@ -517,7 +517,7 @@ class Query(object):
\r
94 :param db: Database to create the query from.
\r
95 :type db: :class:`Database`
\r
96 :param querystr: The query string
\r
97 - :type querystr: str
\r
98 + :type querystr: utf-8 encoded str or unicode
\r
100 :exception: :exc:`NotmuchError`
\r
102 @@ -529,7 +529,9 @@ class Query(object):
\r
103 raise NotmuchError(STATUS.NOT_INITIALIZED)
\r
104 # create reference to parent db to keep it alive
\r
107 + if is_instance(querystr, unicode):
\r
108 + # xapian takes utf-8 encoded byte arrays
\r
109 + querystr = querystr.encode('utf-8')
\r
110 # create query, return None if too little mem available
\r
111 query_p = Query._create(db.db_p, querystr)
\r
112 if query_p is None:
\r