[Lldb-commits] [lldb] [lldb][windows] print an error if Python fails to initialize (PR #181160)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 16 10:10:36 PST 2026
================
@@ -120,14 +120,21 @@ struct InitializePythonRAII {
return spec.GetPath();
}();
if (!g_python_home.empty()) {
- PyConfig_SetBytesString(&config, &config.home, g_python_home.c_str());
+ PyStatus status =
+ PyConfig_SetBytesString(&config, &config.home, g_python_home.c_str());
+ if (PyStatus_Exception(status))
+ llvm::report_fatal_error(llvm::Twine("Failed to set the Python config: '") + status.err_msg + "'.");
}
config.install_signal_handlers = 0;
- Py_InitializeFromConfig(&config);
+ PyStatus status = Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
+ if (PyStatus_Exception(status))
+ llvm::report_fatal_error(llvm::Twine("Python failed to initialize: '") + status.err_msg + "'.");
#else
Py_InitializeEx(/*install_sigs=*/0);
+ if (!Py_IsInitialized())
+ llvm::report_fatal_error("Python failed to initialize.");
----------------
JDevlieghere wrote:
```suggestion
llvm::report_fatal_error("python failed to initialize");
```
https://github.com/llvm/llvm-project/pull/181160
More information about the lldb-commits
mailing list