From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nc9mO6tZB2o1vz0AWB0awg (envelope-from ) for ; Fri, 15 May 2026 13:36:43 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=chO/AOeO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E42991E0B1; Fri, 15 May 2026 13:36:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6C7F51E067 for ; Fri, 15 May 2026 13:36:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F11D84C3184F for ; Fri, 15 May 2026 17:36:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F11D84C3184F Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=chO/AOeO Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 8BFDB40A2493 for ; Fri, 15 May 2026 17:36:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BFDB40A2493 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8BFDB40A2493 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778866575; cv=none; b=aSvvD4IJArISB1zCfHpQDo6XgB8kD1eExtaZ4xKuRRiCt7BPsT1vTiGeyLXVSHIdybezE2crEihjFWInWnkps8h3UnCZjrpvFBVeUpqwAVAxRzqicUk9+B5wOdMdDcvfaSyJatCOamCjzDWWsB4cOB4O6qdY32uyOOZbBgu4jso= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778866575; c=relaxed/simple; bh=PF8qtAqzYEWcP6aeJJeXHOcfzgUXOPdmZd97U/GVWVo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TnKMTnRfKtxUh9Mw4+dbgZcCst/VsLA5anKYlrD3KvUnWlAhCwN+t0anecmtt+9Z8UHMnQXuwSQnypCbG5R3BVYT7YoR9df+ePfa+Yi9O6/aizNSHmnJxmX46m/F1UF44hLOw1B1xfBrCOSLfgZXjZUNlCHtQSneswaQgUvzJAw= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=chO/AOeO reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BFDB40A2493 Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id Ne67wFl2O4RkpNwSNwqL3T; Fri, 15 May 2026 17:36:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id NwSDwInLHkWUFNwSDwSKfd; Fri, 15 May 2026 17:36:05 +0000 X-Authority-Analysis: v=2.4 cv=frTcZE4f c=1 sm=1 tr=0 ts=6a07598e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=NGcC8JguVDcA:10 a=ItBw4LHWJt0A:10 a=TGaGhhJq6TgzRkAm1AcA:9 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=d2bjsLP2L9tfA+MFQ/K9FwD5ezZK46ZjfRg+ArDt4mI=; b=chO/AOeOOJMoZv/QZbf78LCgjh Wtns74jxMf8WdMOLO9QZ8FsMBnpb7PZ5csaZQ4TRBTPHJ07y3ElbL2ePTFAgDmAUUDec6JjL1KLvS 6SOARt2xzfulBCUhhD/nqBs+t; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:37650 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wNwSD-00000001h2Y-0RsA; Fri, 15 May 2026 11:36:05 -0600 From: Tom Tromey To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 1/5] [gdb/python] Introduce py_{none, true, false, notimplemented} functions In-Reply-To: <20260515135834.2502165-1-tdevries@suse.de> (Tom de Vries's message of "Fri, 15 May 2026 15:58:30 +0200") References: <20260515135834.2502165-1-tdevries@suse.de> X-Attribution: Tom Date: Fri, 15 May 2026 11:36:03 -0600 Message-ID: <87h5o8h8xo.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wNwSD-00000001h2Y-0RsA X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net (bapiya) [75.166.225.82]:37650 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLS1fLomA4Jo3ExHxBUb5Umb+V/sdSH/zOR9pDgbP9o/6qdYauTl8clLDUHPGOss6cUbmFEamXHMN3UGKiHHcUAECcNgQKU5SicM5SCw/QHwnNeEvevp CuQOxDzzSq8pf2FF3f9+KEFYBoIdqbIB9va3q4V3Cjr5krPNJbzUip09WGlHNT0LcQcCdoMHSKkTG/F5/yCoYCLKrQwgjtNODew= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org >>>>> "Tom" == Tom de Vries writes: Tom> +/* The following four functions are refcount-safe wrappers around Tom> + Py_RETURN_{NONE,TRUE,FALSE,NOTIMPLEMENTED}. Tom> + Tom> + Starting with python 3.12, None, True, False and Py_NotImplemented are Tom> + immortal, and increasing and decreasing refcount for such objects is a Tom> + no-op, and consequently for the limited C API 3.12 and newer, Tom> + Py_RETURN_NONE is simply "return Py_None". Tom> + Tom> + So for the limited C API 3.12 and newer, we could just return a Tom> + "PyObject *" instead. I don't think this sentence is correct. I mean, it might work in some places, but using this universally would severely uglify gdb because then spots operating generically would have to check specifically for such objects. IMO object immortality is really best thought of as an implementation detail of CPython and not an exposed feature. Tom> + For the limited C API 3.12 and newer, while returning gdbpy_ref<> there's Tom> + an imbalance (we do a Py_DECREF in gdbpy_ref_policy::decref, without Tom> + corresponding Py_INCREF in Py_RETURN_NONE), but this is not harmful because Tom> + Py_DECREF is no-op for immortal objects. */ Tom> +static inline gdbpy_ref<> Tom> +py_notimplemented () Tom> +{ Tom> + auto f = [] { Py_RETURN_NOTIMPLEMENTED; }; Tom> + return gdbpy_ref<> (f ()); Tom> +} I don't think we use this and I think we shouldn't add it until it is needed. Tom