From 2eead96aeba1ec15d258b0952b37cb5d8bfc4c4a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 23 Apr 2025 10:07:09 +0100 Subject: gdb/python: keyword args for Color.__init__ GDB's Python API documentation is clear: Functions and methods which have two or more optional arguments allow them to be specified using keyword syntax. The gdb.Color.__init__ method matches this description, but doesn't support keyword arguments. This commit fixes this by adding keyword argument support. There's a new test to cover this functionality. Approved-By: Tom Tromey --- gdb/python/py-color.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gdb/python') diff --git a/gdb/python/py-color.c b/gdb/python/py-color.c index c48d14e..97801f8 100644 --- a/gdb/python/py-color.c +++ b/gdb/python/py-color.c @@ -176,7 +176,10 @@ colorpy_init (PyObject *self, PyObject *args, PyObject *kwds) PyObject *colorspace_obj = nullptr; color_space colorspace = color_space::MONOCHROME; - if (!PyArg_ParseTuple (args, "|OO", &value_obj, &colorspace_obj)) + static const char *keywords[] = { "value", "color_space", nullptr }; + + if (!gdb_PyArg_ParseTupleAndKeywords (args, kwds, "|OO", keywords, + &value_obj, &colorspace_obj)) return -1; try -- cgit v1.1