From 7cbcf3772f198ebd909e94657532064239b4d503 Mon Sep 17 00:00:00 2001 From: Taeknology <20297177+Taeknology@users.noreply.github.com> Date: Tue, 19 May 2026 12:46:28 +0900 Subject: [PATCH 1/2] gh-149716: Document PySlot_DATA for Py_mod_gil and Py_mod_multiple_interpreters Add short code examples mirroring the existing Py_mod_abi example, so it is clear which slot definition macro (PySlot_DATA, PySlot_INT64, or PySlot_UINT64) to use for these two slots. --- Doc/c-api/module.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 20fd66e35a0d4d..2b22d55f6c724c 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -247,6 +247,14 @@ Feature slots If ``Py_mod_multiple_interpreters`` is not specified, the import machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``. + A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, + as in: + + .. code-block:: c + + PySlot_DATA(Py_mod_multiple_interpreters, + Py_MOD_PER_INTERPRETER_GIL_SUPPORTED) + .. versionadded:: 3.12 .. c:macro:: Py_mod_gil @@ -272,6 +280,13 @@ Feature slots If ``Py_mod_gil`` is not specified, the import machinery defaults to ``Py_MOD_GIL_USED``. + A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, + as in: + + .. code-block:: c + + PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED) + .. versionadded:: 3.13 From 4726cfddd499adb7f12c05d1d763612e1a7970d0 Mon Sep 17 00:00:00 2001 From: Taeknology <20297177+Taeknology@users.noreply.github.com> Date: Tue, 9 Jun 2026 00:55:27 +0900 Subject: [PATCH 2/2] gh-149716: Address review feedback on PySlot_DATA wording Clarify that PySlot_DATA applies to PySlot arrays and note the historical void* declaration of the slot values, per review. --- Doc/c-api/module.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 2b22d55f6c724c..9f68abba66bc5d 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -247,8 +247,9 @@ Feature slots If ``Py_mod_multiple_interpreters`` is not specified, the import machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``. - A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, - as in: + For historical reasons, the values are declared as pointers (``void *``). + When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for + :c:macro:`!Py_mod_multiple_interpreters`: .. code-block:: c @@ -280,8 +281,9 @@ Feature slots If ``Py_mod_gil`` is not specified, the import machinery defaults to ``Py_MOD_GIL_USED``. - A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, - as in: + For historical reasons, the values are declared as pointers (``void *``). + When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for + :c:macro:`!Py_mod_gil`: .. code-block:: c