From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 22 Apr 2012 12:06:20 +0000 (+0200) Subject: Re: [PATCH 7/7] python: wrap and use notmuch_database_destroy as destructor X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a06acca079ee2f93029c404350a8fb214024e251;p=notmuch-archives.git Re: [PATCH 7/7] python: wrap and use notmuch_database_destroy as destructor --- diff --git a/7e/65a6004b53008e1be45adb42a666316d215f83 b/7e/65a6004b53008e1be45adb42a666316d215f83 new file mode 100644 index 000000000..544abed8e --- /dev/null +++ b/7e/65a6004b53008e1be45adb42a666316d215f83 @@ -0,0 +1,123 @@ +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 AD361431FAF + for ; Sun, 22 Apr 2012 05:06:34 -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 WsqtvR1yIoAI for ; + Sun, 22 Apr 2012 05:06:33 -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 07229431FAE + for ; Sun, 22 Apr 2012 05:06:33 -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 67DEC4D42BD + for ; Sun, 22 Apr 2012 14:06:28 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id D4163DF2A2; Sun, 22 Apr 2012 14:06:27 +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 96216DF2A0; + Sun, 22 Apr 2012 14:06:22 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77) + (envelope-from ) + id 1SLvYb-00074l-4C; Sun, 22 Apr 2012 14:06:21 +0200 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +To: Austin Clements , +From: Justus Winter <4winter@informatik.uni-hamburg.de> +In-Reply-To: <20120412170249.GG13549@mit.edu> +References: + <1332291311-28954-1-git-send-email-4winter@informatik.uni-hamburg.de> + <1332291311-28954-8-git-send-email-4winter@informatik.uni-hamburg.de> + <20120412170249.GG13549@mit.edu> +Message-ID: <20120422120620.26225.40778@thinkbox.jade-hamburg.de> +User-Agent: alot/0.3+ +Subject: Re: [PATCH 7/7] python: wrap and use notmuch_database_destroy as + destructor +Date: Sun, 22 Apr 2012 14:06:20 +0200 +Cc: notmuch@notmuchmail.org +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:06:34 -0000 + +Quoting Austin Clements (2012-04-12 19:02:49) +> Quoth Justus Winter on Mar 21 at 1:55 am: +> > Adapt the go bindings to the notmuch_database_close split. +> = + +> Typo. + +Duh >,< + +> > Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> +> > --- +> > bindings/python/notmuch/database.py | 17 +++++++++++++++-- +> > 1 files changed, 15 insertions(+), 2 deletions(-) +> > = + +> > diff --git a/bindings/python/notmuch/database.py b/bindings/python/notm= +uch/database.py +> > index 44d40fd..9a1896b 100644 +> > --- a/bindings/python/notmuch/database.py +> > +++ b/bindings/python/notmuch/database.py +> > @@ -218,9 +218,22 @@ class Database(object): +> > _close.restype =3D 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) +> > + +> > + _destroy =3D nmlib.notmuch_database_destroy +> > + _destroy.argtypes =3D [NotmuchDatabaseP] +> > + _destroy.restype =3D None +> > + +> > + def destroy(self): +> = + +> Should this be __del__? The existing __del__ is certainly wrong with +> this change, since it only closes the database and doesn't free it. I +> think this function is exactly what you want __del__ to be now. +> = + +> (I think it also doesn't make sense to expose notmuch_database_destroy +> as a general, public method since it will free all of the other C +> objects out from under the bindings, resulting in exactly the double +> free-type crashes that you're trying to avoid. It appears that none +> of the other Python classes have a destroy method.) + +Yes, of course... + +I'm going to send an rebased and updated patch series as a follow up +to this message. Thanks for the input everyone :) + +Justus