Skip to content

Commit d2deb8f

Browse files
gh-101100: Fix reference warnings in c-api/init.rst documenting PyGILState_STATE (#139572)
1 parent 6fd1418 commit d2deb8f

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
@@ -1113,7 +1113,7 @@ code, or when embedding the Python interpreter:
11131113
This function is safe to call without an :term:`attached thread state`; it
11141114
will simply return ``NULL`` indicating that there was no prior thread state.
11151115
1116-
.. seealso:
1116+
.. seealso::
11171117
:c:func:`PyEval_ReleaseThread`
11181118
11191119
.. note::
@@ -1124,6 +1124,19 @@ code, or when embedding the Python interpreter:
11241124
The following functions use thread-local storage, and are not compatible
11251125
with sub-interpreters:
11261126
1127+
.. c:type:: PyGILState_STATE
1128+
1129+
The type of the value returned by :c:func:`PyGILState_Ensure` and passed to
1130+
:c:func:`PyGILState_Release`.
1131+
1132+
.. c:enumerator:: PyGILState_LOCKED
1133+
1134+
The GIL was already held when :c:func:`PyGILState_Ensure` was called.
1135+
1136+
.. c:enumerator:: PyGILState_UNLOCKED
1137+
1138+
The GIL was not held when :c:func:`PyGILState_Ensure` was called.
1139+
11271140
.. c:function:: PyGILState_STATE PyGILState_Ensure()
11281141
11291142
Ensure that the current thread is ready to call the Python C API regardless
@@ -1174,12 +1187,12 @@ with sub-interpreters:
11741187
made on the main thread. This is mainly a helper/diagnostic function.
11751188
11761189
.. note::
1177-
This function does not account for :term:`thread states <thread state>` created
1178-
by something other than :c:func:`PyGILState_Ensure` (such as :c:func:`PyThreadState_New`).
1190+
This function may return non-``NULL`` even when the :term:`thread state`
1191+
is detached.
11791192
Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked`
11801193
for most cases.
11811194
1182-
.. seealso: :c:func:`PyThreadState_Get``
1195+
.. seealso:: :c:func:`PyThreadState_Get`
11831196
11841197
.. c:function:: int PyGILState_Check()
11851198
@@ -1278,11 +1291,11 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
12781291
must be :term:`attached <attached thread state>`
12791292
12801293
.. versionchanged:: 3.9
1281-
This function now calls the :c:member:`PyThreadState.on_delete` callback.
1294+
This function now calls the :c:member:`!PyThreadState.on_delete` callback.
12821295
Previously, that happened in :c:func:`PyThreadState_Delete`.
12831296
12841297
.. versionchanged:: 3.13
1285-
The :c:member:`PyThreadState.on_delete` callback was removed.
1298+
The :c:member:`!PyThreadState.on_delete` callback was removed.
12861299
12871300
12881301
.. 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)