Skip to content

Py_tp_bases is not tested #129849

@sobolevn

Description

@sobolevn

Py_tp_bases is defined as a part of our stable ABI, but it is never tested.

» ag Py_tp_bases 
Misc/stable_abi.toml
201:[const.Py_tp_bases]

Include/typeslots.h
50:#define Py_tp_bases 49

Objects/typeobject.c
4590:                case Py_tp_bases:
4601:        PyErr_SetString(PyExc_SystemError, "Py_tp_bases is not a tuple");
4995:        case Py_tp_bases:

Doc/c-api/type.rst
321:   If *bases* is ``NULL``, the *Py_tp_bases* slot is used instead.
555:      Setting :c:data:`Py_tp_bases` or :c:data:`Py_tp_base` may be
585:.. c:macro:: Py_tp_bases

Doc/c-api/typeobj.rst
2009:   For dynamically created classes, the :c:macro:`Py_tp_bases`

So, basically these paths are not covered:

cpython/Objects/typeobject.c

Lines 4590 to 4592 in 80b9e79

case Py_tp_bases:
bases = slot->pfunc;
break;

cpython/Objects/typeobject.c

Lines 4598 to 4602 in 80b9e79

if (PyTuple_Check(bases)) {
return Py_NewRef(bases);
}
PyErr_SetString(PyExc_SystemError, "Py_tp_bases is not a tuple");
return NULL;

However, there are tests that make use of Py_tp_base.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions