[Lldb-commits] [lldb] [lldb] Don't fail initialization when Python can't be loaded (PR #229891)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 7 14:58:33 PDT 2026
================
@@ -49,18 +49,15 @@ llvm::Error SystemInitializerFull::Initialize() {
return error;
#if LLDB_ENABLE_PYTHON
- // Map libpython into the process before any code that might reference it
- // runs. This is required by both the static script interpreter (whose
- // Initialize() invokes Python via the LLDB_PLUGIN_INITIALIZE loop below)
- // and the dynamic plugin (whose dlopen needs Python's symbols visible in
- // the process). The loader is once_flag-cached and a no-op when libpython
- // is already in the process (e.g. `import lldb` from Python).
- llvm::Expected<ScriptInterpreterRuntimeLoader &> python_loader =
- ScriptInterpreterRuntimeLoader::Get(lldb::eScriptLanguagePython);
- if (!python_loader)
- return python_loader.takeError();
- if (llvm::Error err = python_loader->Load())
- return err;
+ // The dynamic script interpreter plugin references Python data symbols (type
+ // and exception objects), which can't be bound lazily, so Python must be
+ // mapped before loading the plugin. Failure isn't fatal, and can be handled
+ // when initializing the plugin.
----------------
JDevlieghere wrote:
@jimingham Updated the comment to point the reader to ScriptInterpreterPython::Initialize. The `Load()` there will return the cached result.
@bulbazord I mentioned this offline to Jim earlier, and the answer is yes, but it's messy. When you have no Python interpreter, we fall back to `ScriptInterpreterNone` which print the error message. It could totally fetch the same cached error, but now `ScriptInterpreterNone` depends on the PythonLoader which works, but is really awful from a layering perspective.
https://github.com/llvm/llvm-project/pull/229891
More information about the lldb-commits
mailing list