--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 2CB6F6DE0924\r
+ for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:02:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.111\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.111 tagged_above=-999 required=5 tests=[AWL=0.111]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id R2eOL-SiqFhU for <notmuch@notmuchmail.org>;\r
+ Sat, 26 Sep 2015 20:02:37 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 7E9CA6DE025E\r
+ for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:02:37 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1Zg2Dq-0005fC-2f; Sun, 27 Sep 2015 03:01:54 +0000\r
+Received: (nullmailer pid 12847 invoked by uid 1000); Sun, 27 Sep 2015\r
+ 03:01:35 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: [PATCH] python: update bindings for new count API\r
+Date: Sun, 27 Sep 2015 00:01:18 -0300\r
+Message-Id: <1443322878-12807-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1443322213-31075-5-git-send-email-david@tethera.net>\r
+References: <1443322213-31075-5-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 27 Sep 2015 03:02:40 -0000\r
+\r
+Note that any mismatches are not detected until runtime (if at all)\r
+with the python bindings, so tests are crucial\r
+---\r
+ bindings/python/notmuch/query.py | 24 ++++++++++++++++--------\r
+ 1 file changed, 16 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py\r
+index 94773ac..378aa47 100644\r
+--- a/bindings/python/notmuch/query.py\r
++++ b/bindings/python/notmuch/query.py\r
+@@ -17,7 +17,7 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>.\r
+ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+ """\r
+ \r
+-from ctypes import c_char_p, c_uint\r
++from ctypes import c_char_p, c_uint, POINTER, byref\r
+ from .globals import (\r
+ nmlib,\r
+ Enum,\r
+@@ -178,8 +178,8 @@ class Query(object):\r
+ raise NullPointerError\r
+ return Messages(msgs_p, self)\r
+ \r
+- _count_messages = nmlib.notmuch_query_count_messages\r
+- _count_messages.argtypes = [NotmuchQueryP]\r
++ _count_messages = nmlib.notmuch_query_count_messages_st\r
++ _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
+ _count_messages.restype = c_uint\r
+ \r
+ def count_messages(self):\r
+@@ -191,10 +191,14 @@ class Query(object):\r
+ :rtype: int\r
+ '''\r
+ self._assert_query_is_initialized()\r
+- return Query._count_messages(self._query)\r
+-\r
+- _count_threads = nmlib.notmuch_query_count_threads\r
+- _count_threads.argtypes = [NotmuchQueryP]\r
++ count = c_uint(0)\r
++ status = Query._count_messages(self._query, byref(count))\r
++ if status != 0:\r
++ raise NotmuchError(status)\r
++ return count.value\r
++\r
++ _count_threads = nmlib.notmuch_query_count_threads_st\r
++ _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
+ _count_threads.restype = c_uint\r
+ \r
+ def count_threads(self):\r
+@@ -210,7 +214,11 @@ class Query(object):\r
+ :rtype: int\r
+ '''\r
+ self._assert_query_is_initialized()\r
+- return Query._count_threads(self._query)\r
++ count = c_uint(0)\r
++ status = Query._count_threads(self._query, byref(count))\r
++ if status != 0:\r
++ raise NotmuchError(status)\r
++ return count.value\r
+ \r
+ _destroy = nmlib.notmuch_query_destroy\r
+ _destroy.argtypes = [NotmuchQueryP]\r
+-- \r
+2.5.3\r
+\r