@@ -1278,7 +1278,7 @@ code, or when embedding the Python interpreter:
1278
1278
This function is safe to call without an :term:`attached thread state`; it
1279
1279
will simply return ``NULL`` indicating that there was no prior thread state.
1280
1280
1281
- .. seealso:
1281
+ .. seealso::
1282
1282
:c:func:`PyEval_ReleaseThread`
1283
1283
1284
1284
.. note::
@@ -1289,6 +1289,19 @@ code, or when embedding the Python interpreter:
1289
1289
The following functions use thread-local storage, and are not compatible
1290
1290
with sub-interpreters:
1291
1291
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
+
1292
1305
.. c:function:: PyGILState_STATE PyGILState_Ensure()
1293
1306
1294
1307
Ensure that the current thread is ready to call the Python C API regardless
@@ -1339,12 +1352,12 @@ with sub-interpreters:
1339
1352
made on the main thread. This is mainly a helper/diagnostic function.
1340
1353
1341
1354
.. note::
1342
- This functiondoes not account for :term:`threadstates <thread state>` created
1343
- by something other than :c:func:`PyGILState_Ensure` (such as :c:func:`PyThreadState_New`) .
1355
+ This functionmay return non-``NULL`` even when the :term:`thread state`
1356
+ is detached .
1344
1357
Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked`
1345
1358
for most cases.
1346
1359
1347
- .. seealso: :c:func:`PyThreadState_Get` `
1360
+ .. seealso:: :c:func:`PyThreadState_Get`
1348
1361
1349
1362
.. c:function:: int PyGILState_Check()
1350
1363
@@ -1443,11 +1456,11 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
1443
1456
must be :term:`attached <attached thread state>`
1444
1457
1445
1458
.. 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.
1447
1460
Previously, that happened in :c:func:`PyThreadState_Delete`.
1448
1461
1449
1462
.. versionchanged:: 3.13
1450
- The :c:member:`PyThreadState.on_delete` callback was removed.
1463
+ The :c:member:`! PyThreadState.on_delete` callback was removed.
1451
1464
1452
1465
1453
1466
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)