[Lldb-commits] [lldb] [lldb] Use Py_InitializeFromConfig with Python >= 3.8 (NFC) (PR #114112)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 30 05:39:31 PDT 2024


================
@@ -117,15 +148,22 @@ struct InitializePythonRAII {
       PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
     }
 
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
+    config.install_signal_handlers = 0;
+    Py_InitializeFromConfig(&config);
+    PyConfig_Clear(&config);
+    InitializeThreadsPrivate();
+#else
 // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
 // calling `Py_Initialize` and `PyEval_InitThreads`.  < 3.2 requires that you
 // call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last.
-#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2)
----------------
labath wrote:

[#if PY_VERSION_HEX>=0x03020000](https://github.com/python/cpython/blob/dcad8fecbd5c8f1542f7a46e0c7bb7e1f27ab115/Include/patchlevel.h#L31) ?

https://github.com/llvm/llvm-project/pull/114112


More information about the lldb-commits mailing list