--- /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 50B206DE1413\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:35:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.108\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.108 tagged_above=-999 required=5 tests=[AWL=0.108]\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 lxlJctPL7Az4 for <notmuch@notmuchmail.org>;\r
+ Sun, 27 Sep 2015 08:35:05 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 715336DE1003\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:35:05 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZgDy3-0008FH-DS; Sun, 27 Sep 2015 15:34:23 +0000\r
+Received: (nullmailer pid 11941 invoked by uid 1000); Sun, 27 Sep 2015\r
+ 15:32:11 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 6/9] python: update bindings for new count API\r
+Date: Sun, 27 Sep 2015 12:32:00 -0300\r
+Message-Id: <1443367923-11867-7-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1443367923-11867-1-git-send-email-david@tethera.net>\r
+References: <1443367923-11867-1-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 15:35:11 -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