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

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 30 06:57:57 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)
----------------
JDevlieghere wrote:

@DavidSpickett The hypothetical Python 4 case is covered above and goes down the ` Py_InitializeFromConfig` path. 

@labath Happy to use that but everything else in this file uses the same check I have here, so I'll simplify the defines in a separate patch/PR. 

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


More information about the lldb-commits mailing list