From 8b737af28bc377db3e661a5744f3b7479b7ce485 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 8 Jan 2022 17:21:43 -0400 Subject: [PATCH 1/5] 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 --- bindings/python-cffi/notmuch2/_database.py | 2 +- bindings/python-cffi/tests/test_config.py | 4 ++-- bindings/python-cffi/tests/test_database.py | 4 ++-- bindings/python-cffi/tests/test_tags.py | 15 +++++++++------ bindings/python-cffi/tests/test_thread.py | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/bindings/python-cffi/notmuch2/_database.py b/bindings/python-cffi/notmuch2/_database.py index 14a8f15c..d7485b4d 100644 --- a/bindings/python-cffi/notmuch2/_database.py +++ b/bindings/python-cffi/notmuch2/_database.py @@ -139,7 +139,7 @@ class Database(base.NotmuchObject): path = os.fsencode(path) return path - def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.EMPTY): + def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.SEARCH): if isinstance(mode, str): mode = self.STR_MODE_MAP[mode] self.mode = mode diff --git a/bindings/python-cffi/tests/test_config.py b/bindings/python-cffi/tests/test_config.py index 1b2695f5..67b0dea4 100644 --- a/bindings/python-cffi/tests/test_config.py +++ b/bindings/python-cffi/tests/test_config.py @@ -23,9 +23,9 @@ class TestIter: def test_set_get(self, maildir): # Ensure get-set works from different db objects - with dbmod.Database.create(maildir.path) as db0: + with dbmod.Database.create(maildir.path, config=dbmod.Database.CONFIG.EMPTY) as db0: db0.config['spam'] = 'ham' - with dbmod.Database(maildir.path) as db1: + with dbmod.Database(maildir.path, config=dbmod.Database.CONFIG.EMPTY) as db1: assert db1.config['spam'] == 'ham' def test_get_keyerror(self, db): diff --git a/bindings/python-cffi/tests/test_database.py b/bindings/python-cffi/tests/test_database.py index 9b3219c0..f1d12ea6 100644 --- a/bindings/python-cffi/tests/test_database.py +++ b/bindings/python-cffi/tests/test_database.py @@ -13,7 +13,7 @@ import notmuch2._message as message @pytest.fixture def db(maildir): - with dbmod.Database.create(maildir.path) as db: + with dbmod.Database.create(maildir.path, config=notmuch2.Database.CONFIG.EMPTY) as db: yield db @@ -293,7 +293,7 @@ class TestQuery: maildir.deliver(body='baz', headers=[('In-Reply-To', '<{}>'.format(msgid))]) notmuch('new') - with dbmod.Database(maildir.path, 'rw') as db: + with dbmod.Database(maildir.path, 'rw', config=notmuch2.Database.CONFIG.EMPTY) as db: yield db def test_count_messages(self, db): diff --git a/bindings/python-cffi/tests/test_tags.py b/bindings/python-cffi/tests/test_tags.py index faf3947b..f2c6209d 100644 --- a/bindings/python-cffi/tests/test_tags.py +++ b/bindings/python-cffi/tests/test_tags.py @@ -23,7 +23,7 @@ class TestImmutable: """ maildir.deliver() notmuch('new') - with database.Database(maildir.path) as db: + with database.Database(maildir.path, config=database.Database.CONFIG.EMPTY) as db: yield db.tags def test_type(self, tagset): @@ -33,7 +33,7 @@ class TestImmutable: def test_hash(self, tagset, maildir, notmuch): h0 = hash(tagset) notmuch('tag', '+foo', '*') - with database.Database(maildir.path) as db: + with database.Database(maildir.path, config=database.Database.CONFIG.EMPTY) as db: h1 = hash(db.tags) assert h0 != h1 @@ -42,7 +42,7 @@ class TestImmutable: def test_neq(self, tagset, maildir, notmuch): notmuch('tag', '+foo', '*') - with database.Database(maildir.path) as db: + with database.Database(maildir.path, config=database.Database.CONFIG.EMPTY) as db: assert tagset != db.tags def test_contains(self, tagset): @@ -159,7 +159,8 @@ class TestMutableTagset: _, pathname = maildir.deliver() notmuch('new') with database.Database(maildir.path, - mode=database.Mode.READ_WRITE) as db: + mode=database.Mode.READ_WRITE, + config=database.Database.CONFIG.EMPTY) as db: msg = db.get(pathname) yield msg.tags @@ -195,7 +196,8 @@ class TestMutableTagset: _, pathname = maildir.deliver(flagged=True) notmuch('new') with database.Database(maildir.path, - mode=database.Mode.READ_WRITE) as db: + mode=database.Mode.READ_WRITE, + config=database.Database.CONFIG.EMPTY) as db: msg = db.get(pathname) msg.tags.discard('flagged') msg.tags.from_maildir_flags() @@ -205,7 +207,8 @@ class TestMutableTagset: _, pathname = maildir.deliver(flagged=True) notmuch('new') with database.Database(maildir.path, - mode=database.Mode.READ_WRITE) as db: + mode=database.Mode.READ_WRITE, + config=database.Database.CONFIG.EMPTY) as db: msg = db.get(pathname) flags = msg.path.name.split(',')[-1] assert 'F' in flags diff --git a/bindings/python-cffi/tests/test_thread.py b/bindings/python-cffi/tests/test_thread.py index 1f44b35d..afdbcfe0 100644 --- a/bindings/python-cffi/tests/test_thread.py +++ b/bindings/python-cffi/tests/test_thread.py @@ -13,7 +13,7 @@ def thread(maildir, notmuch): maildir.deliver(body='bar', headers=[('In-Reply-To', '<{}>'.format(msgid))]) notmuch('new') - with notmuch2.Database(maildir.path) as db: + with notmuch2.Database(maildir.path, config=notmuch2.Database.CONFIG.EMPTY) as db: yield next(db.threads('foo')) From 9e62a0beaa3817b9534f871b896a8ec538a4f090 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 9 Jan 2022 15:29:05 -0400 Subject: [PATCH 2/5] NEWS: add NEWS for 0.34.3 --- NEWS | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/NEWS b/NEWS index 27e43156..e39af344 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,24 @@ +Notmuch 0.34.3 (2022-01-09) +=========================== + +Library +------- + +Do not crash when presented with a .notmuch directory without a +xapian/ subdirectory. + +Python Bindings (notmuch2) +-------------------------- + +Database constructor now searches for configuration by default. Pass +`config=Database.CONFIG.EMPTY` to disable. + +The `Message.replies()` method now returns OwnedMessage objects, to +prevent certain memory de-allocation errors. + +Fix for importing `notmuch2` module when building bindings +documentation. + Notmuch 0.34.2 (2021-12-09) =========================== From ad147c02055982df25848735fc48be3fb378dd40 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 9 Jan 2022 15:31:03 -0400 Subject: [PATCH 3/5] debian: changelog for 0.34.3-1 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index be7bc397..3880a004 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +notmuch (0.34.3-1) unstable; urgency=medium + + * New upstream bugfix release, with several fixes for the notmuch2 + python module. + + -- David Bremner Sun, 09 Jan 2022 15:30:38 -0400 + notmuch (0.34.2-1) unstable; urgency=medium * New upstream bugfix with release, with fixes database location in From a226b7a29b8977003081d96850a1f9e2b9a962b9 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 9 Jan 2022 15:35:12 -0400 Subject: [PATCH 4/5] version: bump to 0.34.3 --- bindings/python-cffi/version.txt | 2 +- bindings/python/notmuch/version.py | 2 +- version.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/python-cffi/version.txt b/bindings/python-cffi/version.txt index 3f8003cd..0aeaf413 100644 --- a/bindings/python-cffi/version.txt +++ b/bindings/python-cffi/version.txt @@ -1 +1 @@ -0.34.2 +0.34.3 diff --git a/bindings/python/notmuch/version.py b/bindings/python/notmuch/version.py index 7a872f5f..d10f9654 100644 --- a/bindings/python/notmuch/version.py +++ b/bindings/python/notmuch/version.py @@ -1,3 +1,3 @@ # this file should be kept in sync with ../../../version -__VERSION__ = '0.34.2' +__VERSION__ = '0.34.3' SOVERSION = '5' diff --git a/version.txt b/version.txt index 3f8003cd..0aeaf413 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.34.2 +0.34.3 From 51c287ead807b6e3830bc5d393a7e9a89f36db86 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 9 Jan 2022 15:35:52 -0400 Subject: [PATCH 5/5] doc: add 2022 to copyright years. --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index c7fd8f5a..e46e1d4e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -14,7 +14,7 @@ master_doc = 'index' # General information about the project. project = u'notmuch' -copyright = u'2009-2021, Carl Worth and many others' +copyright = u'2009-2022, Carl Worth and many others' location = os.path.dirname(__file__)