@@ -37,6 +37,7 @@ The following functions can be safely called before Python is initialized:
37
37
38
38
* Informative functions:
39
39
40
+ * :c:func: `Py_IsInitialized `
40
41
* :c:func: `PyMem_GetAllocator `
41
42
* :c:func: `PyObject_GetArenaAllocator `
42
43
* :c:func: `Py_GetBuildInfo `
@@ -855,6 +856,12 @@ code, or when embedding the Python interpreter:
855
856
created, the current thread must not have acquired it, otherwise deadlock
856
857
ensues.
857
858
859
+ .. note::
860
+ Calling this function from a thread when the runtime is finalizing
861
+ will terminate the thread, even if the thread was not created by Python.
862
+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
863
+ check if the interpreter is in process of being finalized before calling
864
+ this function to avoid unwanted termination.
858
865
859
866
.. c:function:: PyThreadState* PyThreadState_Get()
860
867
@@ -902,6 +909,12 @@ with sub-interpreters:
902
909
When the function returns, the current thread will hold the GIL and be able
903
910
to call arbitrary Python code. Failure is a fatal error.
904
911
912
+ .. note::
913
+ Calling this function from a thread when the runtime is finalizing
914
+ will terminate the thread, even if the thread was not created by Python.
915
+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
916
+ check if the interpreter is in process of being finalized before calling
917
+ this function to avoid unwanted termination.
905
918
906
919
.. c:function:: void PyGILState_Release(PyGILState_STATE)
907
920
@@ -1026,6 +1039,18 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
1026
1039
.. versionadded :: 3.7
1027
1040
1028
1041
1042
+ .. c :function :: PyObject* PyInterpreterState_GetDict (PyInterpreterState *interp)
1043
+
1044
+ Return a dictionary in which interpreter-specific data may be stored.
1045
+ If this function returns *NULL * then no exception has been raised and
1046
+ the caller should assume no interpreter-specific dict is available.
1047
+
1048
+ This is not a replacement for :c:func: `PyModule_GetState() `, which
1049
+ extensions should use to store interpreter-specific state information.
1050
+
1051
+ .. versionadded :: 3.8
1052
+
1053
+
1029
1054
.. c :function :: PyObject* PyThreadState_GetDict ()
1030
1055
1031
1056
Return a dictionary in which extensions can store thread-specific state
@@ -1382,6 +1407,11 @@ These functions are only intended to be used by advanced debugging tools.
1382
1407
Return the interpreter state object at the head of the list of all such objects.
1383
1408
1384
1409
1410
+ .. c:function:: PyInterpreterState* PyInterpreterState_Main()
1411
+
1412
+ Return the main interpreter state object.
1413
+
1414
+
1385
1415
.. c:function:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
1386
1416
1387
1417
Return the next interpreter state object after *interp * from the list of all
0 commit comments