From: Peter Wang Date: Wed, 16 Apr 2014 12:59:18 +0000 (+1000) Subject: [PATCH v2 03/10] python: handle return status of database close and destroy X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a315405438d1c6a198ffcf1f7581c6399e85724;p=notmuch-archives.git [PATCH v2 03/10] python: handle return status of database close and destroy --- diff --git a/97/1a16ab26bb40a95ca600ba0ff1e031683ac0f7 b/97/1a16ab26bb40a95ca600ba0ff1e031683ac0f7 new file mode 100644 index 000000000..c39396ec7 --- /dev/null +++ b/97/1a16ab26bb40a95ca600ba0ff1e031683ac0f7 @@ -0,0 +1,112 @@ +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 944ED431FD8 + for ; Wed, 16 Apr 2014 06:00:17 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 oRmfF7ICliGT for ; + Wed, 16 Apr 2014 06:00:12 -0700 (PDT) +Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com + [209.85.220.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D3ADB431FBF + for ; Wed, 16 Apr 2014 05:59:54 -0700 (PDT) +Received: by mail-pa0-f52.google.com with SMTP id rd3so10871433pab.25 + for ; Wed, 16 Apr 2014 05:59:54 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=ysDXZYN1HSpqRnTThvM90TRhsDZIjKzf1KldDFF1sXk=; + b=ROPpKGs/UmEOoGD7GEzp3L0kdxsaN3Y3SV83+/sy6TXycYukMllXUJXBbtdVCUkL13 + BotG0M+fvq1YXZ4pYFNbtWiMBjKdm2bYc+NIwhRUNN5YD/rN3vS0gHwIwW60O7DyWYau + f7IRdcucurg6UMW0FB+JZGZW8JFNSa4vm/Nr2kRQ84+mpP9k0Rr7AxezsEq4iDvW8eNl + fHXQe0sAJZs2rL2itDk01aVTyrfovaEboB1ejfquqNQ8gOrENmSVJ2vaGD0WAEJWYOkS + JsTNYHwnK10eHYxm13iwgspPrJIx+8bWpqOQzrMZO/0Op7Pl11iZ5bq/QsmveV9ATTM9 + X05w== +X-Received: by 10.68.197.99 with SMTP id it3mr8230605pbc.37.1397653194096; + Wed, 16 Apr 2014 05:59:54 -0700 (PDT) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) by mx.google.com with ESMTPSA id + id10sm46933724pbc.35.2014.04.16.05.59.51 for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Wed, 16 Apr 2014 05:59:52 -0700 (PDT) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH v2 03/10] python: handle return status of database close and + destroy +Date: Wed, 16 Apr 2014 22:59:18 +1000 +Message-Id: <1397653165-15620-4-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.8.4 +In-Reply-To: <1397653165-15620-1-git-send-email-novalazy@gmail.com> +References: <1397653165-15620-1-git-send-email-novalazy@gmail.com> +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: Wed, 16 Apr 2014 13:00:17 -0000 + +Throw an exception if notmuch_database_close or notmuch_database_destroy +fail. +--- + bindings/python/notmuch/database.py | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py +index 7ddf5cf..5b58e09 100644 +--- a/bindings/python/notmuch/database.py ++++ b/bindings/python/notmuch/database.py +@@ -157,11 +157,13 @@ class Database(object): + + _destroy = nmlib.notmuch_database_destroy + _destroy.argtypes = [NotmuchDatabaseP] +- _destroy.restype = None ++ _destroy.restype = c_uint + + def __del__(self): + if self._db: +- self._destroy(self._db) ++ status = self._destroy(self._db) ++ if status != STATUS.SUCCESS: ++ raise NotmuchError(status) + + def _assert_db_is_initialized(self): + """Raises :exc:`NotInitializedError` if self._db is `None`""" +@@ -217,7 +219,7 @@ class Database(object): + + _close = nmlib.notmuch_database_close + _close.argtypes = [NotmuchDatabaseP] +- _close.restype = None ++ _close.restype = c_uint + + def close(self): + ''' +@@ -231,7 +233,9 @@ class Database(object): + NotmuchError. + ''' + if self._db: +- self._close(self._db) ++ status = self._close(self._db) ++ if status != STATUS.SUCCESS: ++ raise NotmuchError(status) + + def __enter__(self): + ''' +-- +1.8.4 +