|
9 | 9 | #include "gtest/gtest.h"
|
10 | 10 |
|
11 | 11 | #include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
|
12 |
| -#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" |
13 |
| -#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h" |
14 | 12 | #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
|
15 | 13 |
|
16 |
| -#include "lldb/Host/FileSystem.h" |
17 |
| -#include "lldb/Host/HostInfo.h" |
18 |
| - |
19 | 14 | #include "PythonTestSuite.h"
|
20 | 15 | #include <optional>
|
21 | 16 |
|
22 |
| -using namespace lldb_private; |
23 |
| -class TestScriptInterpreterPython : public ScriptInterpreterPythonImpl { |
24 |
| -public: |
25 |
| - using ScriptInterpreterPythonImpl::Initialize; |
26 |
| -}; |
27 |
| - |
28 | 17 | void PythonTestSuite::SetUp() {
|
29 |
| - FileSystem::Initialize(); |
30 |
| - HostInfoBase::Initialize(); |
31 |
| - // ScriptInterpreterPython::Initialize() depends on HostInfo being |
32 |
| - // initializedso it can compute the python directory etc. |
33 |
| - TestScriptInterpreterPython::Initialize(); |
34 |
| - |
35 | 18 | // Although we don't care about concurrency for the purposes of running
|
36 | 19 | // this test suite, Python requires the GIL to be locked even for
|
37 | 20 | // deallocating memory, which can happen when you call Py_DECREF or
|
38 | 21 | // Py_INCREF. So acquire the GIL for the entire duration of this
|
39 | 22 | // test suite.
|
| 23 | + Py_InitializeEx(0); |
40 | 24 | m_gil_state = PyGILState_Ensure();
|
| 25 | + PyRun_SimpleString("import sys"); |
41 | 26 | }
|
42 | 27 |
|
43 | 28 | void PythonTestSuite::TearDown() {
|
44 | 29 | PyGILState_Release(m_gil_state);
|
45 | 30 |
|
46 |
| - TestScriptInterpreterPython::Terminate(); |
47 |
| - HostInfoBase::Terminate(); |
48 |
| - FileSystem::Terminate(); |
| 31 | + // We could call Py_FinalizeEx here, but initializing and finalizing Python is |
| 32 | + // pretty slow, so just keep Python initialized across tests. |
49 | 33 | }
|
50 | 34 |
|
51 | 35 | // The following functions are the Pythonic implementations of the required
|
@@ -219,7 +203,7 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
|
219 | 203 | }
|
220 | 204 |
|
221 | 205 | bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
|
222 |
| - PyObject *implementor, lldb::DebuggerSP debugger, |
| 206 | + PyObject *implementor, lldb::DebuggerSP debugger, |
223 | 207 | StructuredDataImpl &args_impl,
|
224 | 208 | lldb_private::CommandReturnObject &cmd_retobj,
|
225 | 209 | lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
|
|
0 commit comments