Re: [PATCH] Use Python safety API in py-symbol.c
Andrew Burgess <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Tom Tromey <[email protected]> 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