@@ -92,25 +92,6 @@ namespace {
92
92
struct InitializePythonRAII {
93
93
public:
94
94
InitializePythonRAII () {
95
- PyConfig config;
96
- PyConfig_InitPythonConfig (&config);
97
-
98
- #if LLDB_EMBED_PYTHON_HOME
99
- static std::string g_python_home = []() -> std::string {
100
- if (llvm::sys::path::is_absolute (LLDB_PYTHON_HOME))
101
- return LLDB_PYTHON_HOME;
102
-
103
- FileSpec spec = HostInfo::GetShlibDir ();
104
- if (!spec)
105
- return {};
106
- spec.AppendPathComponent (LLDB_PYTHON_HOME);
107
- return spec.GetPath ();
108
- }();
109
- if (!g_python_home.empty ()) {
110
- PyConfig_SetBytesString (&config, &config.home , g_python_home.c_str ());
111
- }
112
- #endif
113
-
114
95
// The table of built-in modules can only be extended before Python is
115
96
// initialized.
116
97
if (!Py_IsInitialized ()) {
@@ -134,9 +115,30 @@ struct InitializePythonRAII {
134
115
PyImport_AppendInittab (" _lldb" , LLDBSwigPyInit);
135
116
}
136
117
118
+ #if LLDB_EMBED_PYTHON_HOME
119
+ PyConfig config;
120
+ PyConfig_InitPythonConfig (&config);
121
+
122
+ static std::string g_python_home = []() -> std::string {
123
+ if (llvm::sys::path::is_absolute (LLDB_PYTHON_HOME))
124
+ return LLDB_PYTHON_HOME;
125
+
126
+ FileSpec spec = HostInfo::GetShlibDir ();
127
+ if (!spec)
128
+ return {};
129
+ spec.AppendPathComponent (LLDB_PYTHON_HOME);
130
+ return spec.GetPath ();
131
+ }();
132
+ if (!g_python_home.empty ()) {
133
+ PyConfig_SetBytesString (&config, &config.home , g_python_home.c_str ());
134
+ }
135
+
137
136
config.install_signal_handlers = 0 ;
138
137
Py_InitializeFromConfig (&config);
139
138
PyConfig_Clear (&config);
139
+ #else
140
+ Py_InitializeEx (/* install_sigs=*/ 0 );
141
+ #endif
140
142
141
143
// The only case we should go further and acquire the GIL: it is unlocked.
142
144
PyGILState_STATE gil_state = PyGILState_Ensure ();
0 commit comments