From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] Use Python safety API in py-symbol.c
Date: Mon, 10 Aug 2026 17:37:52 +0100 [thread overview]
Message-ID: <87cxvqkk2n.fsf@redhat.com> (raw)
In-Reply-To: <20260809182352.959293-1-tom@tromey.com>
Tom Tromey <tom@tromey.com> writes:
> This changes py-symbol.c to use the new Python safety API. A new
> wrapper was needed in py-safety.h, but otherwise the patch is
> straightforward.
>
> Regression tested on x86-64 Fedora 40.
> ---
> gdb/python/py-safety.h | 27 ++
> gdb/python/py-symbol.c | 647 +++++++++++++++--------------------
> gdb/python/python-internal.h | 15 +-
> gdb/python/python.c | 20 +-
> 4 files changed, 316 insertions(+), 393 deletions(-)
>
> diff --git a/gdb/python/py-safety.h b/gdb/python/py-safety.h
> index 3294f38c8b6..72b62ec526c 100644
> --- a/gdb/python/py-safety.h
> +++ b/gdb/python/py-safety.h
> @@ -299,6 +299,33 @@ varargs_method (const char *name, const char *doc)
> };
> }
>
> +/* Normally gdb requires that if a method accepts multiple arguments,
> + then it should also accept keywords. However, there are some
> + exceptions to this rule. These exceptions should use this wrapper.
> + This should be used sparingly.
> +
> + A typical exception is something that takes an optional argument.
> + So, it may call PyArg_ParseTuple with "|s" or the like.
> +
> + The underlying method should accept a single gdbpy_borrowed_ref
> + argument, which holds the arguments. */
Would it not be better to just update the function in question to accept
keyword arguments? I know some people dislike using them on single
argument functions, but surely from the GDB side, supporting them is
pretty cheap, then it's up to the user if they want to use them or not?
Thanks,
Andrew
next prev parent reply other threads:[~2026-08-10 16:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 18:23 Tom Tromey
2026-08-10 16:37 ` Andrew Burgess [this message]
2026-08-11 0:16 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cxvqkk2n.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox