Re: [PATCH 7/7] python: wrap and use notmuch_database_destroy as destructor
authorAustin Clements <amdragon@MIT.EDU>
Thu, 12 Apr 2012 17:02:49 +0000 (13:02 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:18 +0000 (09:46 -0800)
13/7cc1c376fcfcc0d310e7d86d514bee2af96a14 [new file with mode: 0644]

diff --git a/13/7cc1c376fcfcc0d310e7d86d514bee2af96a14 b/13/7cc1c376fcfcc0d310e7d86d514bee2af96a14
new file mode 100644 (file)
index 0000000..de4e7fd
--- /dev/null
@@ -0,0 +1,131 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 75F6E431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 10:02:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id MdwwPoKJOapV for <notmuch@notmuchmail.org>;\r
+       Thu, 12 Apr 2012 10:02:52 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
+       [18.9.25.12])\r
+       by olra.theworths.org (Postfix) with ESMTP id CE41B431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 10:02:51 -0700 (PDT)\r
+X-AuditID: 1209190c-b7fad6d000000920-26-4f870abbf7eb\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 47.58.02336.BBA078F4; Thu, 12 Apr 2012 13:02:51 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q3CH2pIU022054; \r
+       Thu, 12 Apr 2012 13:02:51 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3CH2neS025675\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 12 Apr 2012 13:02:50 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SINQ1-0004JP-M2; Thu, 12 Apr 2012 13:02:49 -0400\r
+Date: Thu, 12 Apr 2012 13:02:49 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Subject: Re: [PATCH 7/7] python: wrap and use notmuch_database_destroy as\r
+       destructor\r
+Message-ID: <20120412170249.GG13549@mit.edu>\r
+References:\r
+ <1332291311-28954-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+       <1332291311-28954-8-git-send-email-4winter@informatik.uni-hamburg.de>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <1332291311-28954-8-git-send-email-4winter@informatik.uni-hamburg.de>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IR4hRV1t3N1e5vsPySpMXs1h9MFtdvzmR2\r
+       YPKYeP40m8ezVbeYA5iiuGxSUnMyy1KL9O0SuDIuXLrLXtDMV7H21UzmBsYDXF2MnBwSAiYS\r
+       p5q6WSBsMYkL99azdTFycQgJ7GOUWDDjNSOEs4FR4tuyVrAqIYGTTBJXDoVDJJYwSrz7eokZ\r
+       JMEioCqxq7OPFcRmE9CQ2LZ/OSOILSJgKrHhwQN2EJtZQFri2+9mJhBbWCBM4tH+D2wgNq+A\r
+       jsTFCeuhts1klGh/eJkRIiEocXLmExaIZi2JG/9eAjVzgA1a/o8DJMwpECSxYN8RsBJRARWJ\r
+       KSe3sU1gFJqFpHsWku5ZCN0LGJlXMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Rrq5WaW6KWmlG5i\r
+       BAe2JM8OxjcHlQ4xCnAwKvHwvnzW5i/EmlhWXJl7iFGSg0lJlHc1e7u/EF9SfkplRmJxRnxR\r
+       aU5q8SFGCQ5mJRHeP4+BynlTEiurUovyYVLSHCxK4rwqWu/8hATSE0tSs1NTC1KLYLIyHBxK\r
+       ErwuwAgWEixKTU+tSMvMKUFIM3FwggznARpuDVLDW1yQmFucmQ6RP8WoKCXOqwySEABJZJTm\r
+       wfXCEs8rRnGgV4R57UGqeIBJC677FdBgJqDBfAogVxeXJCKkpBoYNf29ojr317rmlS0p8z/w\r
+       eO7N4yE72FxWFkxX+ZRx+uqBpHXq8oW67BeLk/QyGAUfzMvZc3v67avr/voFngy8ErFnwqZp\r
+       XWr7n5zhvOD9O9efzaBq+hFHAVNe9mslS+p6pWY8erFl+h9jx2O7Tjay3mitnO1kK1pbsHMd\r
+       0+6jtccOmlrdvjRFWYmlOCPRUIu5qDgRABjs77QXAwAA\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 12 Apr 2012 17:02:52 -0000\r
+\r
+Quoth Justus Winter on Mar 21 at  1:55 am:\r
+> Adapt the go bindings to the notmuch_database_close split.\r
+\r
+Typo.\r
+\r
+> \r
+> Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+> ---\r
+>  bindings/python/notmuch/database.py |   17 +++++++++++++++--\r
+>  1 files changed, 15 insertions(+), 2 deletions(-)\r
+> \r
+> diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+> index 44d40fd..9a1896b 100644\r
+> --- a/bindings/python/notmuch/database.py\r
+> +++ b/bindings/python/notmuch/database.py\r
+> @@ -218,9 +218,22 @@ class Database(object):\r
+>      _close.restype = None\r
+>  \r
+>      def close(self):\r
+> -        """Close and free the notmuch database if needed"""\r
+> -        if self._db is not None:\r
+> +        '''\r
+> +        Closes the notmuch database.\r
+> +        '''\r
+> +        if self._db:\r
+>              self._close(self._db)\r
+> +\r
+> +    _destroy = nmlib.notmuch_database_destroy\r
+> +    _destroy.argtypes = [NotmuchDatabaseP]\r
+> +    _destroy.restype = None\r
+> +\r
+> +    def destroy(self):\r
+\r
+Should this be __del__?  The existing __del__ is certainly wrong with\r
+this change, since it only closes the database and doesn't free it.  I\r
+think this function is exactly what you want __del__ to be now.\r
+\r
+(I think it also doesn't make sense to expose notmuch_database_destroy\r
+as a general, public method since it will free all of the other C\r
+objects out from under the bindings, resulting in exactly the double\r
+free-type crashes that you're trying to avoid.  It appears that none\r
+of the other Python classes have a destroy method.)\r
+\r
+> +        '''\r
+> +        Destroys the notmuch database.\r
+> +        '''\r
+> +        if self._db:\r
+> +            self._destroy(self._db)\r
+>              self._db = None\r
+>  \r
+>      def __enter__(self):\r