Commit graph

27 commits

Author SHA1 Message Date
David Bremner
fad2e7540b lib/open: no default mail root in split configurations
If we know the configuration is split, but there is no mail root
defined, this indicates a (lack of) configuration error. Currently
this can only arise in XDG configurations.
2022-01-15 15:59:39 -04:00
David Bremner
63d3b2b5cf notmuch 0.34.3 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmHbOcMACgkQA0U5G1Wq
 FSEGVA//Vjgripk0eRDIUZrdL/knjDXybbHVz06r+gx+9Rh1b+3MJ8t+VAjeX7OO
 iJns7ZysKgMsQSYFCFk9fTl5m3ECzZFmzY7lmRU2tU6Hz9lUwotN70e+zGBgFE6J
 sGji4YOCrUnpmgb0j0joRD565m74Bi2Z8Pj+qRvo4RcQY5JxczyDtkSnLb9UDo/e
 FNZ4bTlwJL13Jeu8F6BtnCFPxvpac3qlzLIlG327Fz4cFwQ+QoxQIq5i8pnOu3B2
 HBEyOZAgIuONbV/RH/nwt7QmT45Dne1wP/UqocHkiu3yKvsCRLZC0vsejw8/dZ+D
 GQUfJT9EL1AIJa6OvUyF5UtnPMRKgACG2nt5U8M02ubheAAEgUS/FIIm1kgxkqYU
 5dDKHwU12YHDW2/nwOSRBFDV6TSCkskXr9Thr884KCobyPPnhWkN+pKAfyDhwPMc
 MrnMyId3fPrJRPMxoQ7Z8TJV8l/Wd6FIlFowfzk+s6hfV2qgOUZJ2Btrfk8596Sy
 np8usullbhFagYQ1+JX3AvVxLYvtFKmxO/qG6TcBmjBui5ABz7wtizfgwDx5eVJr
 GpzJUKFUKAmZW+15nm3oNdEwFOjdvRouKc03Qv5eCU6wSaOtd9efgntDPcso8ycW
 Us13KJIhwmwDJdaqnlmG5TdlJY9qjFu/VGHt4+I1GNQuswXRIo8=
 =hQCB
 -----END PGP SIGNATURE-----

Merge tag '0.34.3'

notmuch 0.34.3 release
2022-01-09 19:34:58 -04:00
David Bremner
8b737af28b bindings/python-cffi: search for config by default
The previous (pre-0.34.2) constructor searched for a config file but
only if the database path was not specified, and only to retrieve
database.path. Neither of the available options (CONFIG.SEARCH or
CONFIG.NONE) matches this semantics exactly, but CONFIG.SEARCH causes
less breakage for people who relied on the old behaviour to set their
database.path [1]. Since it also seems like the friendlier option in
the long run, this commit switches to CONFIG.SEARCH as default.

This requires a certain amount of updating the pytest tests, but most
users will actually have a config file, unlike the test environment.

[1]: id:87fsqijx7u.fsf@metapensiero.it
2022-01-09 15:16:51 -04:00
David Bremner
22e04ed01a Merge branch 'release' 2022-01-09 09:20:56 -04:00
David Bremner
9e7ea628e6 python-cffi: returned OwnedMessage objects from Message.replies
If we return regular Message objects, python will try to destroy them,
and the underlying notmuch object, causing e.g. the crash [1].

[1]: id:87sfu6utxg.fsf@tethera.net
2022-01-08 16:29:41 -04:00
David Bremner
9cc026f3da bindings/python-cffi: add matched property to message objects
Existing users of the legacy python bindings use
message.get_flags(Message.FLAG.MATCH) to determine which messages in a
thread matched. Since the bindings don't provide get_flags anymore,
they should provide a property analogous to the existing "excluded"
property.
2022-01-01 11:48:40 -04:00
David Bremner
f17d75b83c python-cffi: fix out-of-tree build
The main idea is to replace the hack of copying version.txt into the
bindings source with a generated _notmuch_config.py file.

This will mean that the bindings only build after configuring and
building notmuch itself. Given those constraints, "pip install ."
should work.
2021-12-05 09:08:48 -04:00
Floris Bruynooghe
ca4e1d885b Fix error message when using notmuch_status_to_string
The python exception class was incorrectly loading the error message
which resulted in unprintable exception objects.
2021-12-05 08:53:39 -04:00
David Bremner
d7f9572413 python-cffi: switch to notmuch_database_{open,create}_with_config
Since release 0.32, libnotmuch provides searching for database and
configuration paths. This commit changes the python module notmuch2 to
use those facilities.

This fixes the bug reported in [1], along with a couple of the
deprecation warnings in the python bindings.

Database.default_path is deprecated, since it no longer faithfully
reflects what libnotmuch is doing, and it is also no longer used in
the bindings themselves.

This commit choose the default of config=CONFIG.EMPTY (equivalent to
passing "" to notmuch_database_open_with_config).  This makes the
change upward compatible API-wise (at least as far as the test suite
verifies), but changing the default to CONFIG.SEARCH would probably be
more convenient for bindings users.

[1]: id:87h7d4wp6b.fsf@tethera.net
2021-12-04 08:42:31 -04:00
David Bremner
4b361f4d35 python-cffi: fix typos in docstring for Database.default_path
These generate warnings from sphinx doc, which makes it harder to
debug documentation changes. They also corrupt the output.
2021-12-04 08:36:07 -04:00
David Bremner
9ae4188610 lib: add new status code for query syntax errors.
This will help provide more meaningful error messages without special
casing on the client side.
2021-09-04 17:07:19 -07:00
David Bremner
2e39ce6eb5 lib: add NOTMUCH_STATUS_NO_DATABASE
This will allow more precise return values from various open related functions.
2021-03-27 09:26:14 -03:00
David Bremner
55f5e87096 lib: add NOTMUCH_STATUS_DATABASE_EXISTS
It is desirable to distinguish between attempting to create a database
that already exists, and more fatal errors like permission problems.
2021-02-06 19:46:46 -04:00
David Bremner
eea258c0c9 lib: add NOTMUCH_STATUS_NO_CONFIG
This will allow client code to provide more meaningful diagnostics. In
particular it will enable "notmuch new" to continue suggsting the user
run "notmuch setup" to create a config after "notmuch new" is
transitioned to the new  configuration framework.
2021-02-06 19:43:11 -04:00
David Bremner
baf1202fbc bindings/notmuch2: add missing crypto error status codes
These are needed so that the later codes line up numerically.
2021-02-06 19:37:50 -04:00
Johannes Larsen
f01f6405c9 python/notmuch2: fix exclude tag handling
A typo in Database._create_query lost the exclude_tag names during the
string to utf-8 conversion.

Amended by DB: fixed patch format and updated commit message.
2020-12-25 11:25:25 -04:00
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Floris Bruynooghe
776a54a0e4 Support aborting the atomic context
Since it is possible to use an atomic context to abort a number of
changes support this usage.  Because the only way to actually abort
the transaction is to close the database this must also do so.

Amended by db: Note the limitation requiring close is a limitation of
the underlying notmuch API, which should be fixed in a future notmuch
release.
2020-06-16 08:17:39 -03:00
Floris Bruynooghe
2d895a0119 Make messages returned by Thread objects owned
This reverses the logic of StandaloneMessage to instead create a
OwnedMessage.  Only the Thread class allows retrieving messages more
then once so it can explicitly create such messages.

The added test fails with SIGABRT without the fix for the message
re-use in threads being present.
2020-06-16 08:02:02 -03:00
Anton Khirnov
1317579079 python/notmuch2: do not destroy messages owned by a query
Any messages retrieved from a query - either directly via
search_messages() or indirectly via thread objects - are owned by that
query. Retrieving the same message (i.e. corresponding to the same
message ID / database object) several times will always yield the same
C object.

The caller is allowed to destroy message objects owned by a query before
the query itself - which can save memory for long-lived queries.
However, that message must then never be retrieved again from that
query.

The python-notmuch2 bindings will currently destroy every message object
in Message._destroy(), which will lead to an invalid free if the same
message is then retrieved again. E.g. the following python program leads
to libtalloc abort()ing:

import notmuch2
db   = notmuch2.Database(mode = notmuch2.Database.MODE.READ_ONLY)
t    = next(db.threads('*'))
msgs = list(zip(t.toplevel(), t.toplevel()))
msgs = list(zip(t.toplevel(), t.toplevel()))

Fix this issue by creating a subclass of Message, which is used for
"standalone" message which have to be freed by the caller. Message class
is then used only for messages descended from a query, which do not need
to be freed by the caller.
2020-06-16 08:02:02 -03:00
Floris Bruynooghe
1bca41698a python config access: fix style and KeyError bug
This fixes some minor style/pep8 things and adds tests for the new
config support.  Also fixes a bug where KeyError was never raised
on a missing key.
2020-06-15 21:50:03 -03:00
Anton Khirnov
5a58754841 python/notmuch2: add bindings for the database config strings 2020-06-15 21:50:03 -03:00
Floris Bruynooghe
a00f3a1f7a Add missing set methods to tagsets
Even though we use collections.abc.Set which implements all these
methods under their operator names, the actual named variations of
these methods are shockingly missing.  So let's add them manually.
2020-06-15 07:14:11 -03:00
Daniel Kahn Gillmor
93cc4b99df python/notmuch2: fix typo for "destroyed"
Another fix to the docstrings, this time for the English part of the
docstrings, not the Python class name.  No functional changes here.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-12-24 07:13:09 +09:00
Daniel Kahn Gillmor
34c5233894 python/notmuch2: fix typo for ObjectDestroyedError
There is no functional change here, just a fix to a typo in the
docstrings.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-12-24 07:12:51 +09:00
Floris Bruynooghe
1e072204cd Move from _add_message to _index_file API
This moves away from the deprecated notmuch_database_add_message API
and instead uses the notmuch_database_index_file API.  This means
instroducing a class to manage the index options and bumping the
library version requirement to 5.1.
2019-12-03 08:12:30 -04:00
Floris Bruynooghe
e2df30f7a9 Rename package to notmuch2
This is based on a previous discussion on the list where this was more
or less seen as the least-bad option.
2019-12-03 08:12:30 -04:00