Skip to content

Commit 1887a95

Browse files
befelemevstinner
andauthored
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>
1 parent 119fce7 commit 1887a95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+128
-10
lines changed

Include/cpython/modsupport.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
3939
struct _PyArg_Parser *, ...);
4040

4141
#ifdef Py_BUILD_CORE
42-
// Internal; defined here to avoid explicitly including pycore_modsupport.h
43-
#define _Py_INTERNAL_ABI_SLOT \
44-
{Py_mod_abi, (void*) &(PyABIInfo) { \
45-
.abiinfo_major_version = 1, \
46-
.abiinfo_minor_version = 0, \
47-
.flags = PyABIInfo_INTERNAL, \
48-
.build_version = PY_VERSION_HEX, \
49-
.abi_version = PY_VERSION_HEX }} \
50-
///////////////////////////////////////////////////////
42+
// For internal use in stdlib. Needs C99 compound literals.
43+
// Defined here to avoid every stdlib module including pycore_modsupport.h
44+
#define _Py_ABI_SLOT {Py_mod_abi, (void*) &(PyABIInfo) _PyABIInfo_DEFAULT}
5145
#endif

Modules/_abc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ _abcmodule_free(void *module)
976976
}
977977

978978
static PyModuleDef_Slot _abcmodule_slots[] = {
979+
_Py_ABI_SLOT,
979980
{Py_mod_exec, _abcmodule_exec},
980981
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
981982
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_asynciomodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,6 +4394,7 @@ module_exec(PyObject *mod)
43944394
}
43954395

43964396
static struct PyModuleDef_Slot module_slots[] = {
4397+
_Py_ABI_SLOT,
43974398
{Py_mod_exec, module_exec},
43984399
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
43994400
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_bisectmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ bisect_modexec(PyObject *m)
452452
}
453453

454454
static PyModuleDef_Slot bisect_slots[] = {
455+
_Py_ABI_SLOT,
455456
{Py_mod_exec, bisect_modexec},
456457
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
457458
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_bz2module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ _bz2_free(void *module)
783783
}
784784

785785
static struct PyModuleDef_Slot _bz2_slots[] = {
786+
_Py_ABI_SLOT,
786787
{Py_mod_exec, _bz2_exec},
787788
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
788789
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_codecsmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ static PyMethodDef _codecs_functions[] = {
11131113
};
11141114

11151115
static PyModuleDef_Slot _codecs_slots[] = {
1116+
_Py_ABI_SLOT,
11161117
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
11171118
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
11181119
{0, NULL}

Modules/_collectionsmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,7 @@ collections_exec(PyObject *module) {
28732873
#undef ADD_TYPE
28742874

28752875
static struct PyModuleDef_Slot collections_slots[] = {
2876+
_Py_ABI_SLOT,
28762877
{Py_mod_exec, collections_exec},
28772878
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
28782879
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_csv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,7 @@ csv_exec(PyObject *module) {
18331833
}
18341834

18351835
static PyModuleDef_Slot csv_slots[] = {
1836+
_Py_ABI_SLOT,
18361837
{Py_mod_exec, csv_exec},
18371838
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18381839
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6497,6 +6497,7 @@ module_free(void *module)
64976497
}
64986498

64996499
static PyModuleDef_Slot module_slots[] = {
6500+
_Py_ABI_SLOT,
65006501
{Py_mod_exec, _ctypes_mod_exec},
65016502
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
65026503
{Py_mod_gil, Py_MOD_GIL_NOT_USED},

Modules/_curses_panel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ _curses_panel_exec(PyObject *mod)
845845
}
846846

847847
static PyModuleDef_Slot _curses_slots[] = {
848+
_Py_ABI_SLOT,
848849
{Py_mod_exec, _curses_panel_exec},
849850
// XXX gh-103092: fix isolation.
850851
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},

0 commit comments

Comments
 (0)