]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/python: keyword arguments for gdb.Color.escape_sequence
authorAndrew Burgess <aburgess@redhat.com>
Wed, 23 Apr 2025 09:22:32 +0000 (10:22 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 23 Apr 2025 23:13:23 +0000 (00:13 +0100)
commit90fa7d2fd5a26bd0eb933c5cd9297c0e0801dacb
tree73d3eebe09ba0e424945e09f19029e5bf6ab4e10
parent2eead96aeba1ec15d258b0952b37cb5d8bfc4c4a
gdb/python: keyword arguments for gdb.Color.escape_sequence

GDB's Python documentation does make it clear that keywords arguments
are supported for functions that take 2 or more arguments.  The
documentation makes no promise for keyword argument support on
functions that only take a single argument.

That said, I'm a fan of keyword arguments, I think they help document
the code, and make intentions clearer, even for single argument
functions.

As I'm changing gdb.Color anyway (see previous commit), I'd like to
add keyword argument support to gdb.Color.escape_sequence, even though
this is a single argument method.  This should be harmless for anyone
who doesn't want to use keywords, but adds the option for those of us
that do.

I've also removed a redundant check that the 'self' argument was a
gdb.Color object; Python already ensures this is the case.

And I have folded the check that the single argument is a bool into
the gdb_PyArg_ParseTupleAndKeywords call, this means that the error
message will include the incorrect type name now, which should make
debugging issues easier.

Tests have been extended to cover both cases -- it appears the
incorrect argument type error was not previously tested, so it is
now.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/py-color.c
gdb/testsuite/gdb.python/py-color.exp