I am using this code: PyThreadState * thread = PyEval_SaveThread(); PyGILState_STATE gil = PyGILState_Ensure(); // ... PyGILState_Release(gil); PyEval_RestoreThread(thread); In Python 3.11.8 it works well, but when I switched version to 3.12.2, my application is crashing on the first variable, error message is: Fatal Python error: the function must be called with the GIL held, after Python initialization and before Python finalization, but the GIL is released (the current Python thread state is NULL) What is the problem and how can I fix? I know that some changes were introduced between 3.11 and 3.12 with GIL but I did not find any informations about issue that I have. Continue reading...