--- /dev/null
+Return-Path: <wking@tremily.us>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 748216DE1763\r
+ for <notmuch@notmuchmail.org>; Tue, 12 Jan 2016 10:53:12 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.009\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.009 tagged_above=-999 required=5 tests=[AWL=0.110, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Brq3eumAHnCS for <notmuch@notmuchmail.org>;\r
+ Tue, 12 Jan 2016 10:53:10 -0800 (PST)\r
+Received: from resqmta-po-12v.sys.comcast.net (resqmta-po-12v.sys.comcast.net\r
+ [96.114.154.171])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id D6D186DE1749\r
+ for <notmuch@notmuchmail.org>; Tue, 12 Jan 2016 10:53:09 -0800 (PST)\r
+Received: from resomta-po-06v.sys.comcast.net ([96.114.154.230])\r
+ by resqmta-po-12v.sys.comcast.net with comcast\r
+ id 56t71s0034yXVJQ016t9os; Tue, 12 Jan 2016 18:53:09 +0000\r
+Received: from mail.tremily.us ([73.221.72.168])\r
+ by resomta-po-06v.sys.comcast.net with comcast\r
+ id 56r71s00B3dr3C9016r7gE; Tue, 12 Jan 2016 18:51:09 +0000\r
+Received: by mail.tremily.us (Postfix, from userid 1000)\r
+ id 3C4A61B46A23; Tue, 12 Jan 2016 10:51:07 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;\r
+ t=1452624667; bh=9KQIevMJFlLFN6eNLg0J986b/sfueKfcR89hjZf5BJk=;\r
+ h=Date:From:To:Cc:Subject:References:In-Reply-To;\r
+ b=ndpbuq09968eG+lxKq16ezp+2wZj/rd1mpL0l+bWxymMmlXrDIOh0ba93eLovewj5\r
+ 5R8Ug0r3CoYeiJb3nOATELlg8Bfjx81TV/uCaUxX65xLpJBzatup213n0zGARvgOQp\r
+ MOCUK00r971T060m7SQWUlV+Qm9jUoSx26gvJqKY=\r
+Date: Tue, 12 Jan 2016 10:51:07 -0800\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: Konrad Hinsen <konrad.hinsen@fastmail.net>\r
+Cc: notmuch@notmuchmail.org\r
+Subject: Re: Crash with Python bindings\r
+Message-ID: <20160112185107.GA21580@odin.tremily.us>\r
+References: <5694CA65.8010400@fastmail.net>\r
+ <20160112102329.4269.20741@thinkbox.jade-hamburg.de>\r
+ <m1y4budggd.fsf@fastmail.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha1;\r
+ protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4"\r
+Content-Disposition: inline\r
+In-Reply-To: <m1y4budggd.fsf@fastmail.net>\r
+OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8;\r
+ url=http://tremily.us/pubkey.txt\r
+User-Agent: Mutt/1.5.23 (2014-03-12)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+ s=q20140121; t=1452624789;\r
+ bh=E4aoHYRBt7W+gLYX6FangOlEfjZh/14hMvL9kTPBuLI=;\r
+ h=Received:Received:Received:Date:From:To:Subject:Message-ID:\r
+ MIME-Version:Content-Type;\r
+ b=ATZbjW8SGozesO+UsqNPvxVZE7/355bAI3j254gIhKfT+U7YYqoGZOxPFZ3v7Jxyu\r
+ onNbENuRbj61B0ljo6kBJzRQAVqXUaISwwVV37x5pqmeOr99CtLUpNwtwZTtWaW6fp\r
+ DnVgSfa5K4/gT3w7/+1he5y0IgRs6q2WVYSOI6uHp9Iovl25b+35ZOGeWfVE37PH73\r
+ vtkNlO9rWRC1rsSGqcPdlXDcQytClVir4/sgFxtia94azbTuMQSdXigyJZa6xStw7F\r
+ chn/V6MbHnM1oyQQ9ygB0jnuaLVVRtfpj5pWSgX1S2zkVLO4KlI9zcI7QUI8bjccit\r
+ IH5s9xU/XROSQ==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 12 Jan 2016 18:53:12 -0000\r
+\r
+\r
+--YiEDa0DAkWCtVeE4\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On Tue, Jan 12, 2016 at 03:23:46PM +0100, Konrad Hinsen wrote:\r
+> Hi Justus,\r
+>=20\r
+> > So I guess what happens is that Python3 changed how the\r
+> > interpreter environment is torn down and they actually destroy the\r
+> > 'q' object. If that is so, then your data is indeed safe.\r
+>=20\r
+> That reminds me of a recent change in object finalization in Python\r
+> 3:\r
+>=20\r
+> https://www.python.org/dev/peps/pep-0442/\r
+\r
+I'm pretty sure that is what's going on. The PEP landed in Python\r
+3.4, explaining why I don't see this issue in 3.3 [1]. And it has\r
+[2]:\r
+\r
+ In particular, this PEP obsoletes the current guideline that\r
+ "objects with a __del__ method should not be part of a reference\r
+ cycle".\r
+\r
+I'm not sure what the best way is to fix __del__ in our Python\r
+bindings, but if you manage them explicitly:\r
+\r
+ db =3D Database()\r
+ q =3D Query(db, "*")\r
+ del q\r
+ db.close()\r
+ del db\r
+\r
+you can avoid the abort (which happens when q.__del__ is called after\r
+db.__del__). We could make that sort of cleanup easier with context\r
+managers for Query objects (we have them for databases since [3]), and\r
+they look like the only object that keep an internal database\r
+reference:\r
+\r
+ with Database() as db:\r
+ with Query(db, "*") as q:\r
+ # do something with q\r
+ db.close()\r
+\r
+Cheers,\r
+Trevor\r
+\r
+[1]: id:20160112180813.GA20499@odin.tremily.us\r
+[2]: https://www.python.org/dev/peps/pep-0442/#impact\r
+[3]: 36ce7e3c (python: implement the context manager protocol for\r
+ database objects, 2012-02-15, v0.12)\r
+\r
+--=20\r
+This email may be signed or encrypted with GnuPG (http://www.gnupg.org).\r
+For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\r
+\r
+--YiEDa0DAkWCtVeE4\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: OpenPGP digital signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2\r
+\r
+iQIcBAEBAgAGBQJWlUsXAAoJEAPqygegUbGs6PMQAILKu849YAttgTVyM3nar0nK\r
+rA5n0pN+NcnMml88pxRJdc3knL94qmhz89mHk2WFrFqBtodg5D3pnEhgaC+sSG23\r
+63gzTfhAQr98Kjb/R83qnwaulAQKd0Ed0QBNIb9sr0DTs35L4aVwlNnn1ducQqT5\r
+SAUT5uJVMoaaNs9YgNWPN4ov8xN2LdyyA5CYXICn8ZdYqLkJZdAe8QHGW40oQKhY\r
++ERs+wqQQrcxh9REHJ/jZqp4BK3ocL/ULzXVsS5ZhWTZ8K4WIA3y9Nh5eao7bDbm\r
+RduCp3md33Qbw8CnN1zPQJ1XyE4EjK8D0T9+l95kBbBd05R50kKhLWNd/ItTcgn1\r
+Yc9dVOa8itfV8w3KaztlzlSfLTA6Y2P+P5qq33XjKR61n0WNm5QvPWfQp1kpIxyU\r
+k/TlpvbqajMGSOnWLbQZ1XReDCF7taPuoqBknZ02w9hhu8MErGYoQpQiae30a9f9\r
+2YBrourPhW+CXg0Wmqb3z3/uCp7vwUpxA1WgspWueJQSwgG/NgPkYZtb/tqwZe2X\r
+GZsOL3XCZnpSpWsI4Ow82lr1Gj2QhAgJDdZsjhnewCoYyDnTVf0cLDLJxfyKuJCF\r
+0vWAfdhoHjkdIaf6GUGsElSa/7xn0JmlrJeOe7wMRoaasQLjEaaWvQXoeVzBf2YC\r
+CMkNlG1aP5R4egGJjBlg\r
+=b5g/\r
+-----END PGP SIGNATURE-----\r
+\r
+--YiEDa0DAkWCtVeE4--\r