* [python] Threads/Messages inconsistencies
@ 2011-12-24 9:44 Patrick Totzke
0 siblings, 0 replies; only message in thread
From: Patrick Totzke @ 2011-12-24 9:44 UTC (permalink / raw)
To: Notmuch Mailing List
Hi,
I noticed some inconsistencies in the way the bindings
treat Threads and Messages
which in my opinion should look and behave alike.
1. There is no Query.count_threads as an equivalent to
Query.count_messages, although there seems to be a function
`notmuch_query_count_threads` offered by the library
2. The docstring of Query.count_messages falsely states it's
return value is a Messages object, when it in fact returns a long.
3. The docstring of Threads contains a line
"number_of_msgs = len(threads)"
which should be
"number_of_threads = len(threads)"
4. Threads.__len__ smells wrong: I have 10 messages in 9 threads in my inbox,
pazz@brick:~$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import notmuch
>>> d=notmuch.Database()
>>> q=d.create_query('is:inbox and not is:killed')
>>>
>>> q.count_messages()
10L
>>> len(list(q.search_messages()))
10
>>>
>>> len(q.search_threads())
10
>>> list(q.search_threads())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pazz/.local/lib/python2.7/site-packages/notmuch/thread.py", line 121, in next
raise NotmuchError(STATUS.NOT_INITIALIZED)
notmuch.globals.NotInitializedError: Operation on uninitialized object impossible.
>>>
The python session above speaks for itself I believe but this is what I consider
bad behaviour, just to make sure:
* why does list(q.search_messages() go through and list(q.search_threads() fails?
* why does len(q.search_threads()) return 10 and not 9 as expected?
I have corrected the docstrings myself and copied the code from Query.count_messages
to provide a Query.count_threads. The two patches can be pulled from pazz.github.org/notmuch.
The count_threads patch doesn't work however, which is really surprising as the code
is straightforward. When I do a import notmuch after applying the patch, I get:
AttributeError: /usr/local/lib/libnotmuch.so.2: undefined symbol: notmuch_query_count_threads
Best,
/p
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-12-24 9:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-24 9:44 [python] Threads/Messages inconsistencies Patrick Totzke
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).