[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
Fri Feb 13 09:48:11 PST 2026


================
@@ -120,14 +120,30 @@ 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)) {
+        PyConfig_Clear(&config);
+        llvm::WithColor::error()
+            << "Failed to set the Python config: '" << status.err_msg << "'.\n";
+        return;
----------------
JDevlieghere wrote:

If crashing right after is unavoidable, I think we should use `llvm::report_fatal_error` here. Library code shouldn't be writing to stderr and I'm afraid this is setting a bad precedent. If we need to crash, let's commit to it and do it ourselves with a meaningful error message.

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


More information about the lldb-commits mailing list