diff options
Diffstat (limited to 'gdb/python/py-micmd.c')
-rw-r--r-- | gdb/python/py-micmd.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c index 54427d4..72f427f 100644 --- a/gdb/python/py-micmd.c +++ b/gdb/python/py-micmd.c @@ -1,6 +1,6 @@ /* MI Command Set for GDB, the GNU debugger. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -447,12 +447,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_micommands () { micmdpy_object_type.tp_new = PyType_GenericNew; - if (PyType_Ready (&micmdpy_object_type) < 0) - return -1; - - if (gdb_pymodule_addobject (gdb_module, "MICommand", - (PyObject *) &micmdpy_object_type) - < 0) + if (gdbpy_type_ready (&micmdpy_object_type) < 0) return -1; invoke_cst = PyUnicode_FromString ("invoke"); @@ -514,7 +509,16 @@ micmdpy_set_installed (PyObject *self, PyObject *newvalue, void *closure) { struct micmdpy_object *micmd_obj = (struct micmdpy_object *) self; - bool installed_p = PyObject_IsTrue (newvalue); + if (!PyBool_Check (newvalue)) + { + PyErr_Format (PyExc_TypeError, + _("gdb.MICommand.installed must be set to a bool, not %s"), + newvalue == Py_None ? "None" : Py_TYPE(newvalue)->tp_name); + return -1; + } + + bool installed_p = newvalue == Py_True; + if (installed_p == (micmd_obj->mi_command != nullptr)) return 0; @@ -574,9 +578,7 @@ PyTypeObject micmdpy_object_type = { 0, /* tp_alloc */ }; -void _initialize_py_micmd (); -void -_initialize_py_micmd () +INIT_GDB_FILE (py_micmd) { add_setshow_boolean_cmd ("py-micmd", class_maintenance, &pymicmd_debug, |