Skip to content

Commit 08faef8

Browse files
[3.14] gh-101100: Fix reference warnings in c-api/init.rst documenting PyGILState_STATE (GH-139572) (#139832)
Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 17873b9 commit 08faef8

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Doc/c-api/init.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ code, or when embedding the Python interpreter:
12781278
This function is safe to call without an :term:`attached thread state`; it
12791279
will simply return ``NULL`` indicating that there was no prior thread state.
12801280
1281-
.. seealso:
1281+
.. seealso::
12821282
:c:func:`PyEval_ReleaseThread`
12831283
12841284
.. note::
@@ -1289,6 +1289,19 @@ code, or when embedding the Python interpreter:
12891289
The following functions use thread-local storage, and are not compatible
12901290
with sub-interpreters:
12911291
1292+
.. c:type:: PyGILState_STATE
1293+
1294+
The type of the value returned by :c:func:`PyGILState_Ensure` and passed to
1295+
:c:func:`PyGILState_Release`.
1296+
1297+
.. c:enumerator:: PyGILState_LOCKED
1298+
1299+
The GIL was already held when :c:func:`PyGILState_Ensure` was called.
1300+
1301+
.. c:enumerator:: PyGILState_UNLOCKED
1302+
1303+
The GIL was not held when :c:func:`PyGILState_Ensure` was called.
1304+
12921305
.. c:function:: PyGILState_STATE PyGILState_Ensure()
12931306
12941307
Ensure that the current thread is ready to call the Python C API regardless
@@ -1339,12 +1352,12 @@ with sub-interpreters:
13391352
made on the main thread. This is mainly a helper/diagnostic function.
13401353
13411354
.. note::
1342-
This function does not account for :term:`thread states <thread state>` created
1343-
by something other than :c:func:`PyGILState_Ensure` (such as :c:func:`PyThreadState_New`).
1355+
This function may return non-``NULL`` even when the :term:`thread state`
1356+
is detached.
13441357
Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked`
13451358
for most cases.
13461359
1347-
.. seealso: :c:func:`PyThreadState_Get``
1360+
.. seealso:: :c:func:`PyThreadState_Get`
13481361
13491362
.. c:function:: int PyGILState_Check()
13501363
@@ -1443,11 +1456,11 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
14431456
must be :term:`attached <attached thread state>`
14441457
14451458
.. versionchanged:: 3.9
1446-
This function now calls the :c:member:`PyThreadState.on_delete` callback.
1459+
This function now calls the :c:member:`!PyThreadState.on_delete` callback.
14471460
Previously, that happened in :c:func:`PyThreadState_Delete`.
14481461
14491462
.. versionchanged:: 3.13
1450-
The :c:member:`PyThreadState.on_delete` callback was removed.
1463+
The :c:member:`!PyThreadState.on_delete` callback was removed.
14511464
14521465
14531466
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Doc/c-api/descriptor.rst
66
Doc/c-api/float.rst
7-
Doc/c-api/init.rst
87
Doc/c-api/init_config.rst
98
Doc/c-api/intro.rst
109
Doc/c-api/module.rst

0 commit comments

Comments
 (0)