Skip to content

Py_tp_bases is not tested #129849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sobolevn opened this issue Feb 8, 2025 · 0 comments
Open

Py_tp_bases is not tested #129849

sobolevn opened this issue Feb 8, 2025 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir topic-C-API

Comments

@sobolevn
Copy link
Member

sobolevn commented Feb 8, 2025

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.

@sobolevn sobolevn added tests Tests in the Lib/test dir topic-C-API labels Feb 8, 2025
@sobolevn sobolevn self-assigned this Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-C-API
Projects
None yet
Development

No branches or pull requests

1 participant