@@ -420,21 +420,21 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
420
420
run_string.Printf (" %s = dict()" , m_dictionary_name.c_str ());
421
421
422
422
Locker locker (this , Locker::AcquireLock, Locker::FreeAcquiredLock);
423
- PyRun_SimpleString (run_string.GetData ());
423
+ RunSimpleString (run_string.GetData ());
424
424
425
425
run_string.Clear ();
426
426
run_string.Printf (
427
427
" run_one_line (%s, 'import copy, keyword, os, re, sys, uuid, lldb')" ,
428
428
m_dictionary_name.c_str ());
429
- PyRun_SimpleString (run_string.GetData ());
429
+ RunSimpleString (run_string.GetData ());
430
430
431
431
// Reloading modules requires a different syntax in Python 2 and Python 3.
432
432
// This provides a consistent syntax no matter what version of Python.
433
433
run_string.Clear ();
434
434
run_string.Printf (
435
435
" run_one_line (%s, 'from importlib import reload as reload_module')" ,
436
436
m_dictionary_name.c_str ());
437
- PyRun_SimpleString (run_string.GetData ());
437
+ RunSimpleString (run_string.GetData ());
438
438
439
439
// WARNING: temporary code that loads Cocoa formatters - this should be done
440
440
// on a per-platform basis rather than loading the whole set and letting the
@@ -444,20 +444,20 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
444
444
run_string.Printf (
445
445
" run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')" ,
446
446
m_dictionary_name.c_str ());
447
- PyRun_SimpleString (run_string.GetData ());
447
+ RunSimpleString (run_string.GetData ());
448
448
run_string.Clear ();
449
449
450
450
run_string.Printf (" run_one_line (%s, 'import lldb.embedded_interpreter; from "
451
451
" lldb.embedded_interpreter import run_python_interpreter; "
452
452
" from lldb.embedded_interpreter import run_one_line')" ,
453
453
m_dictionary_name.c_str ());
454
- PyRun_SimpleString (run_string.GetData ());
454
+ RunSimpleString (run_string.GetData ());
455
455
run_string.Clear ();
456
456
457
457
run_string.Printf (" run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
458
458
" ')" ,
459
459
m_dictionary_name.c_str (), m_debugger.GetID ());
460
- PyRun_SimpleString (run_string.GetData ());
460
+ RunSimpleString (run_string.GetData ());
461
461
}
462
462
463
463
ScriptInterpreterPythonImpl::~ScriptInterpreterPythonImpl () {
@@ -572,8 +572,8 @@ void ScriptInterpreterPythonImpl::LeaveSession() {
572
572
log->PutCString (" ScriptInterpreterPythonImpl::LeaveSession()" );
573
573
574
574
// Unset the LLDB global variables.
575
- PyRun_SimpleString (" lldb.debugger = None; lldb.target = None; lldb.process "
576
- " = None; lldb.thread = None; lldb.frame = None" );
575
+ RunSimpleString (" lldb.debugger = None; lldb.target = None; lldb.process "
576
+ " = None; lldb.thread = None; lldb.frame = None" );
577
577
578
578
// checking that we have a valid thread state - since we use our own
579
579
// threading and locking in some (rare) cases during cleanup Python may end
@@ -674,7 +674,7 @@ bool ScriptInterpreterPythonImpl::EnterSession(uint16_t on_entry_flags,
674
674
run_string.PutCString (" ')" );
675
675
}
676
676
677
- PyRun_SimpleString (run_string.GetData ());
677
+ RunSimpleString (run_string.GetData ());
678
678
run_string.Clear ();
679
679
680
680
PythonDictionary &sys_module_dict = GetSysModuleDictionary ();
@@ -816,9 +816,9 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine(
816
816
817
817
if (!command.empty ()) {
818
818
// We want to call run_one_line, passing in the dictionary and the command
819
- // string. We cannot do this through PyRun_SimpleString here because the
819
+ // string. We cannot do this through RunSimpleString here because the
820
820
// command string may contain escaped characters, and putting it inside
821
- // another string to pass to PyRun_SimpleString messes up the escaping. So
821
+ // another string to pass to RunSimpleString messes up the escaping. So
822
822
// we use the following more complicated method to pass the command string
823
823
// directly down to Python.
824
824
llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
@@ -3057,7 +3057,7 @@ void ScriptInterpreterPythonImpl::Initialize() {
3057
3057
// Update the path python uses to search for modules to include the current
3058
3058
// directory.
3059
3059
3060
- PyRun_SimpleString (" import sys" );
3060
+ RunSimpleString (" import sys" );
3061
3061
AddToSysPath (AddLocation::End, " ." );
3062
3062
3063
3063
// Don't denormalize paths when calling file_spec.GetPath(). On platforms
@@ -3069,10 +3069,10 @@ void ScriptInterpreterPythonImpl::Initialize() {
3069
3069
if (FileSpec file_spec = HostInfo::GetShlibDir ())
3070
3070
AddToSysPath (AddLocation::Beginning, file_spec.GetPath (false ));
3071
3071
3072
- PyRun_SimpleString (" sys.dont_write_bytecode = 1; import "
3073
- " lldb.embedded_interpreter; from "
3074
- " lldb.embedded_interpreter import run_python_interpreter; "
3075
- " from lldb.embedded_interpreter import run_one_line" );
3072
+ RunSimpleString (" sys.dont_write_bytecode = 1; import "
3073
+ " lldb.embedded_interpreter; from "
3074
+ " lldb.embedded_interpreter import run_python_interpreter; "
3075
+ " from lldb.embedded_interpreter import run_one_line" );
3076
3076
3077
3077
#if LLDB_USE_PYTHON_SET_INTERRUPT
3078
3078
// Python will not just overwrite its internal SIGINT handler but also the
@@ -3084,13 +3084,13 @@ void ScriptInterpreterPythonImpl::Initialize() {
3084
3084
// normal Python REPL signal handler which raises a KeyboardInterrupt.
3085
3085
// Also make sure to not pollute the user's REPL with the signal module nor
3086
3086
// our utility function.
3087
- PyRun_SimpleString (" def lldb_setup_sigint_handler():\n "
3088
- " import signal;\n "
3089
- " def signal_handler(sig, frame):\n "
3090
- " raise KeyboardInterrupt()\n "
3091
- " signal.signal(signal.SIGINT, signal_handler);\n "
3092
- " lldb_setup_sigint_handler();\n "
3093
- " del lldb_setup_sigint_handler\n " );
3087
+ RunSimpleString (" def lldb_setup_sigint_handler():\n "
3088
+ " import signal;\n "
3089
+ " def signal_handler(sig, frame):\n "
3090
+ " raise KeyboardInterrupt()\n "
3091
+ " signal.signal(signal.SIGINT, signal_handler);\n "
3092
+ " lldb_setup_sigint_handler();\n "
3093
+ " del lldb_setup_sigint_handler\n " );
3094
3094
#endif
3095
3095
}
3096
3096
@@ -3106,7 +3106,7 @@ void ScriptInterpreterPythonImpl::AddToSysPath(AddLocation ___location,
3106
3106
statement.append (path);
3107
3107
statement.append (" \" )" );
3108
3108
}
3109
- PyRun_SimpleString (statement.c_str ());
3109
+ RunSimpleString (statement.c_str ());
3110
3110
}
3111
3111
3112
3112
// We are intentionally NOT calling Py_Finalize here (this would be the logical
0 commit comments