Re: BiDi
[notmuch-archives.git] / ed / 5091e05190a5e91db283bcd205b73d0e6367d5
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 DF25D431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 02:49:50 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.1\r
10 X-Spam-Level: \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 zNSDJ9xjeWRL for <notmuch@notmuchmail.org>;\r
17         Mon, 11 Jul 2011 02:49:50 -0700 (PDT)\r
18 Received: from homiemail-a75.g.dreamhost.com (caiajhbdcaid.dreamhost.com\r
19         [208.97.132.83])\r
20         by olra.theworths.org (Postfix) with ESMTP id F1677431FB6\r
21         for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 02:49:49 -0700 (PDT)\r
22 Received: from homiemail-a75.g.dreamhost.com (localhost [127.0.0.1])\r
23         by homiemail-a75.g.dreamhost.com (Postfix) with ESMTP id 779745EC080;\r
24         Mon, 11 Jul 2011 02:49:49 -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         l3EUwu+SpWuPNHljU+Kxo227v/5f+Fp6PR1ruo0Ta3etLPaXQRBOr8MAXs6RzCE6\r
28         fErMVTe+0vEMqfPebgzjacx96pOwGRqLvoj9axW88VY37F6H+qXZKJ+Q27ge3/Bg\r
29         Ly7J1cerhwGVHpBUtcuilzeb3Ed4nvDqmd0GuqP3lAg=\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=175vwMuKSmu9VyFuoDKEEZOxiyQ=; b=nFus8RoetO7Z4LYmo2x/0n2UtecM\r
33         7kPkYR5L7pKvO9QY3wpEZ4NK/zem5a+EwDQ5WZ4wn+LUKYGu9Wv+gHc3qCh4Kij/\r
34         DomE/GSTuwwAXeFCSvZKiQbO1131LmwqNxcAirv+reKSbPcCXetIebU2FZNBjrpN\r
35         QwqfVjK3Vkh4BAA=\r
36 Received: from spaetzbook.sspaeth.de (mtec-hg-docking-1-dhcp-253.ethz.ch\r
37         [129.132.133.253])\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-a75.g.dreamhost.com (Postfix) with ESMTPSA id C85945EC07E; \r
42         Mon, 11 Jul 2011 02:49:47 -0700 (PDT)\r
43 Received: by spaetzbook.sspaeth.de (sSMTP sendmail emulation);\r
44         Mon, 11 Jul 2011 11:49:46 +0200\r
45 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH v2] python: Encode query string as a utf-8 byte array\r
48 Date: Mon, 11 Jul 2011 11:49:45 +0200\r
49 Message-Id: <1310377785-7887-1-git-send-email-Sebastian@SSpaeth.de>\r
50 X-Mailer: git-send-email 1.7.4.1\r
51 In-Reply-To: <1310377427-7656-1-git-send-email-Sebastian@SSpaeth.de>\r
52 References: <1310377427-7656-1-git-send-email-Sebastian@SSpaeth.de>\r
53 Cc: Patrick Totzke <patricktotzke@googlemail.com>\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\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:49:51 -0000\r
67 \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
72 \r
73 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
74 ---\r
75 DOH, I should test my patches for typos before actually sending them off. This one should be fine.\r
76 \r
77  bindings/python/notmuch/database.py |    8 +++++---\r
78  1 files changed, 5 insertions(+), 3 deletions(-)\r
79 \r
80 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
81 index 3770b13..84cf79b 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
90          """\r
91          self._db = None\r
92          self._query = None\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
99          :returns: Nothing\r
100          :exception: :exc:`NotmuchError`\r
101  \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
105          self._db = db\r
106 -        \r
107 +        if isinstance(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
113 -- \r
114 1.7.4.1\r
115 \r