[Lldb-commits] [lldb] [lldb] Only use PyConfig when LLDB_EMBED_PYTHON_HOME is enabled (PR #152588)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 7 14:14:55 PDT 2025


================
@@ -134,9 +115,30 @@ struct InitializePythonRAII {
       PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
     }
 
+#if LLDB_EMBED_PYTHON_HOME
----------------
JDevlieghere wrote:

Part of it, yes, but you could avoid changing the order by splitting the ifdef-ed code in two, which is slightly messier. I enabled `LLDB_EMBED_PYTHON_HOME` on Darwin and there it doesn't matter. That would look like this:

```
#if LLDB_EMBED_PYTHON_HOME
  PyConfig config;
  [...]
  PyConfig_SetBytesString(&config, &config.home, g_python_home.c_str());
#endif 

  if (!Py_IsInitialized()) {
  	[...]
    PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
  }
  
#if LLDB_EMBED_PYTHON_HOME  
    config.install_signal_handlers = 0;
    Py_InitializeFromConfig(&config);
    PyConfig_Clear(&config);
#else
    Py_InitializeEx(/*install_sigs=*/0);
#endif
```

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


More information about the lldb-commits mailing list