1 Return-Path: <bremner@tethera.net>
\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 arlo.cworth.org (Postfix) with ESMTP id 2CB6F6DE0924
\r
6 for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:02:40 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.111 tagged_above=-999 required=5 tests=[AWL=0.111]
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id R2eOL-SiqFhU for <notmuch@notmuchmail.org>;
\r
16 Sat, 26 Sep 2015 20:02:37 -0700 (PDT)
\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id 7E9CA6DE025E
\r
19 for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:02:37 -0700 (PDT)
\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
\r
21 (envelope-from <bremner@tethera.net>)
\r
22 id 1Zg2Dq-0005fC-2f; Sun, 27 Sep 2015 03:01:54 +0000
\r
23 Received: (nullmailer pid 12847 invoked by uid 1000); Sun, 27 Sep 2015
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
27 Subject: [PATCH] python: update bindings for new count API
\r
28 Date: Sun, 27 Sep 2015 00:01:18 -0300
\r
29 Message-Id: <1443322878-12807-1-git-send-email-david@tethera.net>
\r
30 X-Mailer: git-send-email 2.5.3
\r
31 In-Reply-To: <1443322213-31075-5-git-send-email-david@tethera.net>
\r
32 References: <1443322213-31075-5-git-send-email-david@tethera.net>
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.18
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Sun, 27 Sep 2015 03:02:40 -0000
\r
47 Note that any mismatches are not detected until runtime (if at all)
\r
48 with the python bindings, so tests are crucial
\r
50 bindings/python/notmuch/query.py | 24 ++++++++++++++++--------
\r
51 1 file changed, 16 insertions(+), 8 deletions(-)
\r
53 diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py
\r
54 index 94773ac..378aa47 100644
\r
55 --- a/bindings/python/notmuch/query.py
\r
56 +++ b/bindings/python/notmuch/query.py
\r
57 @@ -17,7 +17,7 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
58 Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
61 -from ctypes import c_char_p, c_uint
\r
62 +from ctypes import c_char_p, c_uint, POINTER, byref
\r
63 from .globals import (
\r
66 @@ -178,8 +178,8 @@ class Query(object):
\r
67 raise NullPointerError
\r
68 return Messages(msgs_p, self)
\r
70 - _count_messages = nmlib.notmuch_query_count_messages
\r
71 - _count_messages.argtypes = [NotmuchQueryP]
\r
72 + _count_messages = nmlib.notmuch_query_count_messages_st
\r
73 + _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]
\r
74 _count_messages.restype = c_uint
\r
76 def count_messages(self):
\r
77 @@ -191,10 +191,14 @@ class Query(object):
\r
80 self._assert_query_is_initialized()
\r
81 - return Query._count_messages(self._query)
\r
83 - _count_threads = nmlib.notmuch_query_count_threads
\r
84 - _count_threads.argtypes = [NotmuchQueryP]
\r
86 + status = Query._count_messages(self._query, byref(count))
\r
88 + raise NotmuchError(status)
\r
89 + return count.value
\r
91 + _count_threads = nmlib.notmuch_query_count_threads_st
\r
92 + _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)]
\r
93 _count_threads.restype = c_uint
\r
95 def count_threads(self):
\r
96 @@ -210,7 +214,11 @@ class Query(object):
\r
99 self._assert_query_is_initialized()
\r
100 - return Query._count_threads(self._query)
\r
101 + count = c_uint(0)
\r
102 + status = Query._count_threads(self._query, byref(count))
\r
104 + raise NotmuchError(status)
\r
105 + return count.value
\r
107 _destroy = nmlib.notmuch_query_destroy
\r
108 _destroy.argtypes = [NotmuchQueryP]
\r