mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
gdb: add new helpers for retrieving a type's fully qualified name
Py_TYPE (self)->tp_name is the traditional idiomatic way to get a Python type's fully qualified name. However, in the context of the Python limited API, PyTypeObject is opaque, so the 'tp_name' attribute is no longer accessible. Additionally, retrieving the type of a Python object requires Py_TYPE, which is only available as part of the stable API starting with Python 3.14. This patch increases minimal Python limited API version from 3.11 to 3.14. It also introduces two new helpers to retrieve a type's fully qualified name: gdb_py_tp_name() and gdbpy_py_obj_tp_name(), which extract the fully qualified name from a PyTypeObject and a PyObject, respectively. Ifdefery allows these wrappers to select the appropriate API depending on the Python version and whether the Python limited API is enabled. For any Python version less than 3.13, gdb_py_tp_name() fallbacks using __qualname__ instead. However, the result may differ slightly in some cases, e.g. the module name may be missing. Finally, this patch adapts the existing code to use these wrappers, and adjusts some test expectations to use the fully qualified name (or __qualname__ for versions <= 3.13) where it was not previously used. Note that the corner case where the module name would be missing does not appear in the testsuite. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
b1cc575c42
commit
e3998113f9
24 changed files with 169 additions and 55 deletions
|
|
@ -1579,7 +1579,7 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
|
|||
PyErr_Format
|
||||
(PyExc_TypeError,
|
||||
_("'style' argument must be gdb.Style or None, not %s."),
|
||||
Py_TYPE (style_obj)->tp_name);
|
||||
gdbpy_py_obj_tp_name (style_obj));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue