Skip to content

Commit ed0e4fe

Browse files
authored
Update module slot definitions to use PySlot from PEP 820
1 parent 43538cf commit ed0e4fe

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Doc/howto/freethreading-stable-abi.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,19 @@ Extensions that use :ref:`multi-phase initialization <multi-phase-initialization
6161
:c:data:`Py_mod_gil` slot in the module definition.
6262
If your extension supports older versions of CPython,
6363
you should guard the slot with a :c:data:`Py_GIL_DISABLED` check.
64+
Additionally, prefer :c:type:`PySlot` over :c:type:`PyModuleDef_Slot`.
6465

6566
::
6667

67-
static struct PyModuleDef_Slot module_slots[] = {
68+
static PySlot module_slots[] = {
6869
...
6970
#ifdef Py_GIL_DISABLED
70-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
71+
PySlot_STATIC_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED),
7172
#endif
72-
{0, NULL}
73+
PySlot_END
7374
};
7475

75-
Additionally, using ``PyABIInfo_VAR`` and ``Py_mod_abi`` is recommended so that an
76+
Furthermore, using ``PyABIInfo_VAR`` and ``Py_mod_abi`` is recommended so that an
7677
extension module loaded for an incompatible interpreter will trigger an exception, rather than
7778
fail with a crash.
7879

@@ -82,12 +83,12 @@ fail with a crash.
8283
PyABIInfo_VAR(abi_info);
8384
#endif Py_GIL_DISABLED
8485
85-
static PyModuleDef_Slot mymodule_slots[] = {
86+
static PySlot mymodule_slots[] = {
8687
...
8788
#ifdef PY_VERSION_HEX >= 0x030F0000
88-
{Py_mod_abi, &abi_info},
89+
PySlot_STATIC_DATA(Py_mod_abi, &abi_info),
8990
#endif
90-
{0, NULL}
91+
PySlot_END
9192
};
9293
9394
Single-Phase Initialization

0 commit comments

Comments
 (0)