@@ -1113,7 +1113,7 @@ code, or when embedding the Python interpreter:
1113
1113
This function is safe to call without an :term:`attached thread state`; it
1114
1114
will simply return ``NULL`` indicating that there was no prior thread state.
1115
1115
1116
- .. seealso:
1116
+ .. seealso::
1117
1117
:c:func:`PyEval_ReleaseThread`
1118
1118
1119
1119
.. note::
@@ -1124,6 +1124,19 @@ code, or when embedding the Python interpreter:
1124
1124
The following functions use thread-local storage, and are not compatible
1125
1125
with sub-interpreters:
1126
1126
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
+
1127
1140
.. c:function:: PyGILState_STATE PyGILState_Ensure()
1128
1141
1129
1142
Ensure that the current thread is ready to call the Python C API regardless
@@ -1174,12 +1187,12 @@ with sub-interpreters:
1174
1187
made on the main thread. This is mainly a helper/diagnostic function.
1175
1188
1176
1189
.. 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 .
1179
1192
Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked`
1180
1193
for most cases.
1181
1194
1182
- .. seealso: :c:func:`PyThreadState_Get` `
1195
+ .. seealso:: :c:func:`PyThreadState_Get`
1183
1196
1184
1197
.. c:function:: int PyGILState_Check()
1185
1198
@@ -1278,11 +1291,11 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
1278
1291
must be :term:`attached <attached thread state>`
1279
1292
1280
1293
.. 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.
1282
1295
Previously, that happened in :c:func:`PyThreadState_Delete`.
1283
1296
1284
1297
.. versionchanged:: 3.13
1285
- The :c:member:`PyThreadState.on_delete` callback was removed.
1298
+ The :c:member:`! PyThreadState.on_delete` callback was removed.
1286
1299
1287
1300
1288
1301
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
0 commit comments