aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings
diff options
context:
space:
mode:
authorGravatar Justus Winter <4winter@informatik.uni-hamburg.de>2012-04-22 14:07:57 +0200
committerGravatar David Bremner <bremner@debian.org>2012-04-28 09:31:12 -0300
commit7bfc4bf501af2207123135065b08bd4874446de8 (patch)
tree898250801bcc013836aebb59d25865cd0d53b6bb /bindings
parent288feb7cdf1798408c708394fd935f05acf87985 (diff)
python: wrap and use notmuch_database_destroy as destructor
Adapt the python bindings to the notmuch_database_close split. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/notmuch/database.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index 44d40fdb..268e9522 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -161,8 +161,13 @@ class Database(object):
else:
self.create(path)
+ _destroy = nmlib.notmuch_database_destroy
+ _destroy.argtypes = [NotmuchDatabaseP]
+ _destroy.restype = None
+
def __del__(self):
- self.close()
+ if self._db:
+ self._destroy(self._db)
def _assert_db_is_initialized(self):
"""Raises :exc:`NotInitializedError` if self._db is `None`"""
@@ -218,10 +223,11 @@ class Database(object):
_close.restype = None
def close(self):
- """Close and free the notmuch database if needed"""
- if self._db is not None:
+ '''
+ Closes the notmuch database.
+ '''
+ if self._db:
self._close(self._db)
- self._db = None
def __enter__(self):
'''