Skip to content

Commit 15d1b4e

Browse files
author
Enrico Granata
committed
Initialize the Python script interpreter lazily (i.e. not at debugger startup)
This time it should also pass the gtests llvm-svn: 266103
1 parent b390d8e commit 15d1b4e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ ScriptInterpreterPython::ScriptInterpreterPython(CommandInterpreter &interpreter
274274
m_lock_count(0),
275275
m_command_thread_state(nullptr)
276276
{
277-
assert(g_initialized && "ScriptInterpreterPython created but InitializePrivate has not been called!");
277+
InitializePrivate();
278278

279279
m_dictionary_name.append("_dict");
280280
StreamString run_string;
@@ -330,8 +330,6 @@ ScriptInterpreterPython::Initialize()
330330

331331
std::call_once(g_once_flag, []()
332332
{
333-
InitializePrivate();
334-
335333
PluginManager::RegisterPlugin(GetPluginNameStatic(),
336334
GetPluginDescriptionStatic(),
337335
lldb::eScriptLanguagePython,
@@ -3097,7 +3095,9 @@ ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback swig_init_callb
30973095
void
30983096
ScriptInterpreterPython::InitializePrivate ()
30993097
{
3100-
assert(!g_initialized && "ScriptInterpreterPython::InitializePrivate() called more than once!");
3098+
if (g_initialized)
3099+
return;
3100+
31013101
g_initialized = true;
31023102

31033103
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);

lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PythonTestSuite::SetUp()
2424
// ScriptInterpreterPython::Initialize() depends on HostInfo being
2525
// initializedso it can compute the python directory etc.
2626
ScriptInterpreterPython::Initialize();
27+
ScriptInterpreterPython::InitializePrivate();
2728

2829
// Although we don't care about concurrency for the purposes of running
2930
// this test suite, Python requires the GIL to be locked even for

0 commit comments

Comments
 (0)