From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oEApHiTf2WGATAAAgWs5BA (envelope-from ) for ; Sat, 08 Jan 2022 19:59:48 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YGLgFiTf2WFjMAAAG6o9tA (envelope-from ) for ; Sat, 08 Jan 2022 19:59:48 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 218891BC5B for ; Sat, 8 Jan 2022 19:59:48 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8B7865F724; Sat, 8 Jan 2022 18:59:44 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by mail.notmuchmail.org (Postfix) with ESMTPS id 6E1255F70B for ; Sat, 8 Jan 2022 18:59:41 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id q8so17990745wra.12 for ; Sat, 08 Jan 2022 10:59:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version; bh=xRhdDLUh5FwjsjFozQ5hyuRUXF8D+vTVppeWCekxrdY=; b=OpjJce0njNtjxxpiFZVGYRMjA7ck7xP+3ELianjYUYHwmWbgAPR3E7uiNHqz+ZaBY+ sF26Jo5OxNSgQ4Y21lmxxQ9iVW2dkK0i78rICwAS1myPdZAyYfezLS8DIBkSeVNVM4LT F1wJWt1xVSzBmWa5m8dUXX7jyUhlws2v0XuZ2wcYLAgSmIGXEgTNMNbYJyLWC50AKhzw icI8+X2fS6Dcv7lZjojGdgtUNnaLmV1nQxGULp/LOrB4pIRgVqFSiks0h0V1jnrWszoU HSwQCrpjj5Tp0421VPWX2fa9WKF9Y5cWPrkS9yRRmQ7VyXdGUk7pMzt32QEVPVnFyx6t dUHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:in-reply-to:references :date:message-id:mime-version; bh=xRhdDLUh5FwjsjFozQ5hyuRUXF8D+vTVppeWCekxrdY=; b=PBzkXlaR+zehhjJLYf4zzv1wc3Z/zcwpogPqzJPhRcjZ8HQIrPNm/58FAbGth4jgUY kZK9Vk66lodXSDbCfmjctKxG+YW7zOTRax/m8Whf7W4+QfHmXfaX3FaTZcP70lC1uzr+ OXxPiJBpdkUchwSk3numXgRuDJGeca91FP8vELOzuTRmuQ3vU4G2a8M32lUFrhdGXZ/Z O9SYx+wA0RY4oozahtYjr+MgncfIgdmiH6kU70vAuKhR9jSH/o1yIHVYx0tn+n2MCw5w Udid3C+SvOm9f01v9qqUMZdoC4ZkeLvhgGxT39clA6zY/dQJhSL0Bk3cylFdx9vNsDsg M1Uw== X-Gm-Message-State: AOAM533p6i69eY8z4NCDW1WCV0uYBk8d3jkJheS2S0QUlFsvpkFGtKg4 vr4xoHx90dqw4VynEJ9GriMo4EE9uVc= X-Google-Smtp-Source: ABdhPJx4WvIKllKmbfj/VsV3oGdGYqzO3CGwsXyOvJw1Y6j30P2+Qk69nSSp9qFx+4KBXl8qYFsZHQ== X-Received: by 2002:a5d:5253:: with SMTP id k19mr1602226wrc.228.1641668380717; Sat, 08 Jan 2022 10:59:40 -0800 (PST) Received: from powell.devork.be (62-178-226-148.cable.dynamic.surfer.at. [62.178.226.148]) by smtp.gmail.com with ESMTPSA id j11sm2779548wmq.23.2022.01.08.10.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jan 2022 10:59:40 -0800 (PST) Sender: Floris Bruynooghe Received: (nullmailer pid 202145 invoked by uid 1000); Sat, 08 Jan 2022 18:59:39 -0000 From: Floris Bruynooghe To: David Bremner , David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/2] python-cffi: returned OwnedMessage objects from Message.replies In-Reply-To: <20220108140316.3022887-2-david@tethera.net> References: <87o84nu23h.fsf@tethera.net> <20220108140316.3022887-1-david@tethera.net> <20220108140316.3022887-2-david@tethera.net> Date: Sat, 08 Jan 2022 19:59:39 +0100 Message-ID: <87a6g6aw9w.fsf@powell.devork.be> MIME-Version: 1.0 Message-ID-Hash: KIO5MHTD4QHHDBBNNN3RP53L7TNIEN4Q X-Message-ID-Hash: KIO5MHTD4QHHDBBNNN3RP53L7TNIEN4Q X-MailFrom: floris.bruynooghe@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641668388; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=35jCAGywAzia7kcBwOSLIfNWejSJX+z9/JyiLscEaRc=; b=dQRLOfNGzYEGBJxDaVCyQXaMG0ok2lRP4yzkJdKbSin1PgI1M/n9Mnzg1PbHspQZD9qGpX xKP+xeuEG1lIDT9b3ZANefr/muNWffseVTKpHYM2uDs67ZiH9YuGPvUKO5Fx2PcuiSQmHf EQFYdT+omwsfMgwcFcL49euO0yocdBXg3ufpDRP1xkNF6KkxW+tHEwrL6m0hphvwxr5uWx v21KN4FkUOnIf5tywB8CQIxoKesBZp2za6GoAhNiYWzcb8TkWqw86Djj/8NGcT0TEGvOQb IyAhTaZMDFQB0w592Qg+z4Pxwot5mOQgglSj00PzMBt6EwzdJsVV4wUvNgY0jg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641668388; a=rsa-sha256; cv=none; b=qneLcEQ5FUKX444fow/lufRQgWsraoLz4ntKE79L8fSSDncE+mc3KLeFJx6TjC5FpLArNO FUq696iw0vn6e3KuQJZh5lWLx9QwYsD/1iDiWaq8Z/smUVYf/v0DTpAK/AlaJaURVpuMuC APVMOOcttJEIbc5MN9RewcJhXL9SgotWHErgN5h2b/3SK94CSuSxIE/B/ms9p9yclX1z2C pkS4AdxxDhQ8Ij0ZeobwH3lyPJOHkBWVZ/ACxTjNI8Byhdg8cSx4aR+h1zXZipgt31+hgm SVYaZCdF1ro+ap3OJikClGifZsXr7AsOXuApg7pxdcCQVSJK7pgqHFKznPB50g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=OpjJce0n; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.29 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=OpjJce0n; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 218891BC5B X-Spam-Score: -1.29 X-Migadu-Scanner: scn1.migadu.com X-TUID: JuKqlIV91VYs On Sat 08 Jan 2022 at 10:03 -0400, David Bremner wrote: > If we return regular Message objects, python will try to destroy them, > and the underlying notmuch object, causing e.g. the crash [1]. > > [1]: id:87sfu6utxg.fsf@tethera.net > --- > bindings/python-cffi/notmuch2/_message.py | 4 ++-- > test/T392-python-cffi-notmuch.sh | 2 -- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/bindings/python-cffi/notmuch2/_message.py b/bindings/python-cffi/notmuch2/_message.py > index a460d8c1..aa1cb875 100644 > --- a/bindings/python-cffi/notmuch2/_message.py > +++ b/bindings/python-cffi/notmuch2/_message.py > @@ -371,14 +371,14 @@ class Message(base.NotmuchObject): > This method will only work if the message was created from a > thread. Otherwise it will yield no results. > > - :returns: An iterator yielding :class:`Message` instances. > + :returns: An iterator yielding :class:`OwnedMessage` instances. > :rtype: MessageIter > """ > # The notmuch_messages_valid call accepts NULL and this will > # become an empty iterator, raising StopIteration immediately. > # Hence no return value checking here. > msgs_p = capi.lib.notmuch_message_get_replies(self._msg_p) > - return MessageIter(self, msgs_p, db=self._db) > + return MessageIter(self, msgs_p, db=self._db, msg_cls=OwnedMessage) > > def __hash__(self): > return hash(self.messageid) > diff --git a/test/T392-python-cffi-notmuch.sh b/test/T392-python-cffi-notmuch.sh > index 50012c55..15c8fc6b 100755 > --- a/test/T392-python-cffi-notmuch.sh > +++ b/test/T392-python-cffi-notmuch.sh > @@ -24,13 +24,11 @@ show_msgs(thread, 0) > EOF > > test_begin_subtest "recursive traversal of replies (no crash)" > -test_subtest_known_broken > test_python < recurse.py > error=$? > test_expect_equal "${error}" 0 > > test_begin_subtest "recursive traversal of replies (output)" > -test_subtest_known_broken > test_python < recurse.py > tail -n 10 < OUTPUT > OUTPUT.sample > cat < EXPECTED oh, nice debugging! And yes, this seems like the right fix, glad the mechanism was at least already in place. With respect to the docs, they seem clear enough. Probably I missed this or I simply didn't realise that the replies iter is basically a thread owning it. Only thing I'd do different is write a pytest test for this as well, but than I wouldn't have written the notmuch tests. So I don't think this matters that much. Cheers, Floris