From b2929bebb6ce8d75acab4f2fde43213673cb6010 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Mon, 30 Oct 2023 08:55:34 -0300 Subject: [lldb] Adapt code to Python 3.13 (#70445) 1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads Both of these functions were removed in Python 3.13 [1] after being deprecated since Python 3.9. According to "What's new in Python 3.13" document [1]: Since Python 3.7, Py_Initialize() always creates the GIL: calling PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized() always returned non-zero. 2. Replace _Py_IsFinalizing() with Py_IsFinalizing(). [1] https://docs.python.org/3.13/whatsnew/3.13.html --- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 9ac840a..fe3438c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -71,7 +71,9 @@ Expected python::As(Expected &&obj) { } static bool python_is_finalizing() { -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 +#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3) + return Py_IsFinalizing(); +#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 return _Py_Finalizing != nullptr; #else return _Py_IsFinalizing(); -- cgit v1.1