[python] Threads/Messages inconsistencies
authorPatrick Totzke <patricktotzke@googlemail.com>
Sat, 24 Dec 2011 09:44:47 +0000 (09:44 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:15 +0000 (09:41 -0800)
24/c0e64f7ab075b704d996f54cc90019aecf18b9 [new file with mode: 0644]

diff --git a/24/c0e64f7ab075b704d996f54cc90019aecf18b9 b/24/c0e64f7ab075b704d996f54cc90019aecf18b9
new file mode 100644 (file)
index 0000000..948ab53
--- /dev/null
@@ -0,0 +1,134 @@
+Return-Path: <patricktotzke@googlemail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5FD06431FD0\r
+       for <notmuch@notmuchmail.org>; Sat, 24 Dec 2011 01:44:54 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 3nL75edUxOpI for <notmuch@notmuchmail.org>;\r
+       Sat, 24 Dec 2011 01:44:53 -0800 (PST)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 8CE1C431FB6   for <notmuch@notmuchmail.org>; Sat, 24 Dec 2011 01:44:53 -0800\r
+ (PST)\r
+Received: by eekd41 with SMTP id d41so11917994eek.26\r
+       for <notmuch@notmuchmail.org>; Sat, 24 Dec 2011 01:44:50 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=googlemail.com; s=gamma;\r
+       h=message-id:content-type:mime-version:content-transfer-encoding:to\r
+       :from:subject:date;\r
+       bh=ovP8dasaK99hPg2+CLvj6PzPokE5IMGrff2UVB+PRxg=;\r
+       b=uOCdwE8+l5pUHXZjOicf9NhBTGMTElLOloyvBoLIbpADfH31QVYsj2ffoqlYhJhfSR\r
+       EtSi+Fpx7LT6MyDZbGmZbG+X/QoycyHpcOIN4CWbK/WjKDgRA4NIu0TZrINTwyg9I1j6\r
+       t8Lj1heT2Zc0Ru/x3aerwcYqANS8bOQyR/NxI=\r
+Received: by 10.14.100.193 with SMTP id z41mr7224111eef.113.1324719890845;\r
+       Sat, 24 Dec 2011 01:44:50 -0800 (PST)\r
+Received: from localhost (g224022183.adsl.alicedsl.de. [92.224.22.183])\r
+       by mx.google.com with ESMTPS id b49sm29320584eec.9.2011.12.24.01.44.49\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 24 Dec 2011 01:44:49 -0800 (PST)\r
+Message-ID: <4ef59f11.c9330e0a.78cb.324c@mx.google.com>\r
+Content-Type: text/plain; charset="utf-8"\r
+MIME-Version: 1.0\r
+Content-Transfer-Encoding: quoted-printable\r
+To: Notmuch Mailing List <notmuch@notmuchmail.org>\r
+From: Patrick Totzke <patricktotzke@googlemail.com>\r
+Subject: [python] Threads/Messages inconsistencies\r
+Date: Sat, 24 Dec 2011 09:44:47 +0000\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Sat, 24 Dec 2011 09:44:54 -0000\r
+\r
+Hi,\r
+\r
+I noticed some inconsistencies in the way the bindings\r
+treat Threads and Messages\r
+which in my opinion should look and behave alike.\r
+\r
+1. There is no Query.count_threads as an equivalent to\r
+   Query.count_messages, although there seems to be a function\r
+   `notmuch_query_count_threads` offered by the library\r
+\r
+2. The docstring of Query.count_messages falsely states it's\r
+   return value is a Messages object, when it in fact returns a long.\r
+\r
+3. The docstring of Threads contains a line =\r
+\r
+   "number_of_msgs =3D len(threads)"\r
+   which should be\r
+   "number_of_threads =3D len(threads)"\r
+\r
+4. Threads.__len__ smells wrong: I have 10 messages in 9 threads in my inbo=\r
+x,\r
+\r
+   pazz@brick:~$ python\r
+   Python 2.7.2+ (default, Oct  4 2011, 20:06:09) =\r
+\r
+   [GCC 4.6.1] on linux2\r
+   Type "help", "copyright", "credits" or "license" for more information.\r
+   >>> import notmuch\r
+   >>> d=3Dnotmuch.Database()\r
+   >>> q=3Dd.create_query('is:inbox and not is:killed')\r
+   >>> =\r
+\r
+   >>> q.count_messages()\r
+   10L\r
+   >>> len(list(q.search_messages()))\r
+   10\r
+   >>> =\r
+\r
+   >>> len(q.search_threads())\r
+   10\r
+   >>> list(q.search_threads())\r
+   Traceback (most recent call last):\r
+     File "<stdin>", line 1, in <module>\r
+     File "/home/pazz/.local/lib/python2.7/site-packages/notmuch/thread.py"=\r
+, line 121, in next\r
+       raise NotmuchError(STATUS.NOT_INITIALIZED)\r
+   notmuch.globals.NotInitializedError: Operation on uninitialized object i=\r
+mpossible.\r
+   >>> =\r
+\r
+\r
+   The python session above speaks for itself I believe but this is what I =\r
+consider\r
+   bad behaviour, just to make sure:\r
+   * why does list(q.search_messages() go through and list(q.search_threads=\r
+() fails?\r
+   * why does len(q.search_threads()) return 10 and not 9 as expected?\r
+\r
+\r
+\r
+I have corrected the docstrings myself and copied the code from Query.count=\r
+_messages\r
+to provide a Query.count_threads. The two patches can be pulled from pazz.g=\r
+ithub.org/notmuch.\r
+The count_threads patch doesn't work however, which is really surprising as=\r
+ the code\r
+is straightforward. When I do a import notmuch after applying the patch, I =\r
+get:\r
+\r
+  AttributeError: /usr/local/lib/libnotmuch.so.2: undefined symbol: notmuch=\r
+_query_count_threads\r
+\r
+Best,\r
+/p\r