From c059c1396461ad8491722b812a1411ce34e3623c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 22 Apr 2012 14:07:57 +0200 Subject: [PATCH] [PATCH 7/7] python: wrap and use notmuch_database_destroy as destructor --- c0/75203aeca42dbfb209c74f7464027b239df327 | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 c0/75203aeca42dbfb209c74f7464027b239df327 diff --git a/c0/75203aeca42dbfb209c74f7464027b239df327 b/c0/75203aeca42dbfb209c74f7464027b239df327 new file mode 100644 index 000000000..af187b679 --- /dev/null +++ b/c0/75203aeca42dbfb209c74f7464027b239df327 @@ -0,0 +1,106 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BDE33431FD7 + for ; Sun, 22 Apr 2012 05:08:55 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id J7DHpRNB5WSo for ; + Sun, 22 Apr 2012 05:08:55 -0700 (PDT) +Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3B193431FD0 + for ; Sun, 22 Apr 2012 05:08:55 -0700 (PDT) +Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.cryptobitch.de (Postfix) with ESMTPSA id B34475836F8 + for ; Sun, 22 Apr 2012 14:08:53 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id 23226DF2A2; Sun, 22 Apr 2012 14:08:53 +0200 (CEST) +Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.153]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) (Authenticated sender: teythoon) + by mail.jade-hamburg.de (Postfix) with ESMTPSA id 327E1DF2A6; + Sun, 22 Apr 2012 14:08:29 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77) + (envelope-from ) + id 1SLvad-0007B9-GV; Sun, 22 Apr 2012 14:08:27 +0200 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +To: notmuch@notmuchmail.org +Subject: [PATCH 7/7] python: wrap and use notmuch_database_destroy as + destructor +Date: Sun, 22 Apr 2012 14:07:57 +0200 +Message-Id: + <1335096477-27537-7-git-send-email-4winter@informatik.uni-hamburg.de> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: + <1335096477-27537-1-git-send-email-4winter@informatik.uni-hamburg.de> +References: <20120422120620.26225.40778@thinkbox.jade-hamburg.de> + <1335096477-27537-1-git-send-email-4winter@informatik.uni-hamburg.de> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 22 Apr 2012 12:08:56 -0000 + +Adapt the python bindings to the notmuch_database_close split. + +Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> +--- + bindings/python/notmuch/database.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py +index 44d40fd..268e952 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): + ''' +-- +1.7.10 + -- 2.26.2