gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770)

Rename from _Py_INTERNAL_ABI_SLOT to _Py_ABI_SLOT
and define the macro using _PyABIInfo_DEFAULT.

Use the ABI slot in stdlib extension modules to enable running
a check of ABI version compatibility.

_tkinter, _tracemalloc and readline don't use the slots, hence they need
explicit handling.

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Karolina Surma 2026-03-24 18:47:55 +01:00 committed by GitHub
parent 119fce7b88
commit 1887a95f51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
96 changed files with 128 additions and 10 deletions

1
Python/Python-ast.c generated
View file

@ -18480,6 +18480,7 @@ astmodule_exec(PyObject *m)
}
static PyModuleDef_Slot astmodule_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, astmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

View file

@ -400,6 +400,7 @@ static PyMethodDef tokenize_methods[] = {
};
static PyModuleDef_Slot tokenizemodule_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, tokenizemodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

View file

@ -43,6 +43,7 @@ _contextvars_exec(PyObject *m)
}
static struct PyModuleDef_Slot _contextvars_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, _contextvars_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

View file

@ -1626,6 +1626,7 @@ warnings_module_exec(PyObject *module)
static PyModuleDef_Slot warnings_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, warnings_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

View file

@ -5714,6 +5714,7 @@ imp_module_exec(PyObject *module)
static PyModuleDef_Slot imp_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, imp_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

View file

@ -2135,6 +2135,7 @@ marshal_module_exec(PyObject *mod)
}
static PyModuleDef_Slot marshalmodule_slots[] = {
_Py_ABI_SLOT,
{Py_mod_exec, marshal_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},