From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8+IkITGKD2qNkA0AWB0awg (envelope-from ) for ; Thu, 21 May 2026 18:41:53 -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=sGHYwW1e; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 731341E091; Thu, 21 May 2026 18:41:53 -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 F2A501E024 for ; Thu, 21 May 2026 18:41:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5875E4BA799A for ; Thu, 21 May 2026 22:41:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5875E4BA799A 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=sGHYwW1e Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id EE52B4BABF2E for ; Thu, 21 May 2026 22:41:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE52B4BABF2E 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 EE52B4BABF2E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779403285; cv=none; b=ssnvygmHuiWcRgk9EeFHu4R71Z2U5IKYmgNxK3t2hEoixbBdRR7sUhE8Eocx8uTC2Luu1K37LrIx8hP+FeVDs/IeFLtSii3DMp4bjH/4aWUjyi2FlEo0qjPyPPL2c8HWrdxV5WG9WEc0U1QF5TBemmIOXl3+8UGzHWgRfiBXFu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779403285; c=relaxed/simple; bh=sxjGljkr6flDcefs79y3SZZVAv9TpFsv/xPG0jg2H88=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dPhfG1jNzTYW/rM4zg+5RJlDtXM93562euIiutdQM2BZ7dhGiOgfrHdhLIylrwSe9o4n/lFNfnDePQ2NBR5eNdpn9iiD1VmDJNcI1yKS1xOwgN5rskUn2pO0YOY7VwkHdfqqbLq+6pPjNY11El4wl2c6PiGXHcMhstGWdVxbyz0= 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=sGHYwW1e reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE52B4BABF2E Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id Q3tTwPguhjgweQC4xwgsgu; Thu, 21 May 2026 22:41:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QC4wwRHF1DvkeQC4ww22E5; Thu, 21 May 2026 22:41:22 +0000 X-Authority-Analysis: v=2.4 cv=RaOQC0tv c=1 sm=1 tr=0 ts=6a0f8a12 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=NGcC8JguVDcA:10 a=ItBw4LHWJt0A:10 a=XEU9cLjiiBPsExeuILUA: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=z1OcFBgLkO21S3sanN31DjdqYgunL0G/xI+pju9Hhiw=; b=sGHYwW1eZk+VCla+e4SPagWk68 66nVHwmd8AHfV4RsCLjb7OekOmwe2LrYavqtRSa/nPLnSj77pkQfou0PDqxtiS29eN/V4p/4tQK1A efUWUGg7FpTUi55GP/AZRz7/Y; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:34002 helo=prentzel) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wQC4v-000000021mo-3uVs; Thu, 21 May 2026 16:41:22 -0600 From: Tom Tromey To: Andrew Burgess Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH v2 3/4] Add wrappers for Python implementation functions and methods In-Reply-To: <874ik5ca1g.fsf@redhat.com> (Andrew Burgess's message of "Mon, 18 May 2026 11:00:11 +0100") References: <20260515-python-safety-initial-v2-0-6129cadf258a@tromey.com> <20260515-python-safety-initial-v2-3-6129cadf258a@tromey.com> <874ik5ca1g.fsf@redhat.com> X-Attribution: Tom Date: Thu, 21 May 2026 16:41:19 -0600 Message-ID: <871pf4jshc.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: 1wQC4v-000000021mo-3uVs X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net (prentzel) [75.166.225.82]:34002 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIKpOoCm9xd7R1NhgSJDRotzIcDpKaKCIBkbYzUE88foOLT3RLr+ekFWEEHEfM0HSu5gmrvMoftxTBl9sZBNvSFMTIUvmFApaQuRkG7QJm7EfRbkg7gn cMSmBAqh9/NR7Xp5EmEXJ/1GzLBw7JPdm5EIKuVbGQiFmCig0YPDDh8+2NvQNJAcwnkAY/FeIlxaIdJFJcp52uiNa2iOgnhGiNY= 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 >> Note this patch is not 100% complete. There should be one more >> wrapper for case where a method takes a single argument (though we >> probably cannot use METH_O unfortunately). There may be some other >> holes as well. Andrew> Maybe reword this so it doesn't imply that THIS patch is not complete, Andrew> but rather the implementation as a whole is not complete and will Andrew> require future follow on patches. What you've got is good enough to Andrew> start using it. I updated the text a bit. >> +template> Andrew> I think the SFINAE part here is wrong, like in the previous commit. I Andrew> think gdb::Requires> might be what you mean. Fixed. Andrew> None of the to_python functions check their return values for error, for Andrew> example PyUnicode_Decode can fail and return NULL, but you don't check Andrew> for this. Andrew> But this is OK. to_python is only used at the point where we transition Andrew> back from GDB's C++ code to the Python internals, so if PyUnicode_Decode Andrew> (for example) returns NULL and sets an exception, this will be caught by Andrew> Python. Andrew> I have two pieces of feedback on this: Andrew> 1. I think this should be explicitly called out in the comment above Andrew> the to_python functions, rather than making everyone figure out that Andrew> this is not a mistake. I updated the comment that precedes the to_python functions as a whole. >> + /* Note that this cannot fail. */ Andrew> Is (IMHO) confusing. It implies the lack of error checking here is Andrew> because PyBool_FromLong cannot fail, which is why, when I look at Andrew> later to_python functions which include calls that *can* fail, I Andrew> asked myself, where's the error checking. Andrew> I think this comment should just go. Deleted. >> + gdbpy_borrowed_ref or gdbpy_opt_borrowed_ref), and then then calls Andrew> typo: ".... then THEN calls ..." Fixed. >> +/* An instantiation of this function is used when calling a gdb method >> + from Python. It accepts some number of arguments (normally >> + gdbpy_borrowed_ref or gdbpy_opt_borrowed_ref), and then then calls >> + the underlying function F. Any exceptions are caught and >> + converted, and the return value of F is converted to a Python >> + object as appropriate. */ Andrew> This comment needs updating. It also include the 'then then' typo from Andrew> the wrapped_function comment, but also references function F, when it Andrew> should be taking about method CLASS::METH or maybe just METH? Anyway, Andrew> certainly not F. Fixed. >> +/* A function that wraps a "repr" or "str" method. */ >> +template Andrew> In wrap_setter below you are explicit about the signature of M. I much Andrew> prefer the explicit form, but here in wrap_repr and in wrap_getter you Andrew> use 'auto'. Could we switch to the explicit form in these two too? There are two issues with changing. One is that while a setter should probably just return void, a getter could return anything. And, requiring a specific return type for tp_str or tp_repr seems a bit heavy, like maybe it would be convenient to return std::string in some spots or gdbpy_ref<> in others. The other issue is that 'auto' means it automatically accepts const- or non-const-methods. This can be handled by overloads of course. Anyway I left this as is but we can discuss further if you want. Tom