@@ -1067,23 +1067,6 @@ void ScriptInterpreterPythonImpl::ExecuteInterpreterLoop() {
1067
1067
}
1068
1068
1069
1069
bool ScriptInterpreterPythonImpl::Interrupt () {
1070
- // PyErr_SetInterrupt was introduced in 3.2.
1071
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
1072
- // If the interpreter isn't evaluating any Python at the moment then return
1073
- // false to signal that this function didn't handle the interrupt and the
1074
- // next component should try handling it.
1075
- if (!IsExecutingPython ())
1076
- return false ;
1077
-
1078
- // Tell Python that it should pretend to have received a SIGINT.
1079
- PyErr_SetInterrupt ();
1080
- // PyErr_SetInterrupt has no way to return an error so we can only pretend the
1081
- // signal got successfully handled and return true.
1082
- // Python 3.10 introduces PyErr_SetInterruptEx that could return an error, but
1083
- // the error handling is limited to checking the arguments which would be
1084
- // just our (hardcoded) input signal code SIGINT, so that's not useful at all.
1085
- return true ;
1086
- #else
1087
1070
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT));
1088
1071
1089
1072
if (IsExecutingPython ()) {
@@ -1105,7 +1088,6 @@ bool ScriptInterpreterPythonImpl::Interrupt() {
1105
1088
" ScriptInterpreterPythonImpl::Interrupt() python code not running, "
1106
1089
" can't interrupt" );
1107
1090
return false ;
1108
- #endif
1109
1091
}
1110
1092
1111
1093
bool ScriptInterpreterPythonImpl::ExecuteOneLineWithReturn (
@@ -3311,28 +3293,6 @@ ScriptInterpreterPythonImpl::AcquireInterpreterLock() {
3311
3293
return py_lock;
3312
3294
}
3313
3295
3314
- namespace {
3315
- // / Saves the current signal handler for the specified signal and restores
3316
- // / it at the end of the current scope.
3317
- struct RestoreSignalHandlerScope {
3318
- // / The signal handler.
3319
- struct sigaction m_prev_handler;
3320
- int m_signal_code;
3321
- RestoreSignalHandlerScope (int signal_code) : m_signal_code(signal_code) {
3322
- // Initialize sigaction to their default state.
3323
- std::memset (&m_prev_handler, 0 , sizeof (m_prev_handler));
3324
- // Don't install a new handler, just read back the old one.
3325
- struct sigaction *new_handler = nullptr ;
3326
- int signal_err = ::sigaction (m_signal_code, new_handler, &m_prev_handler);
3327
- lldbassert (signal_err == 0 && " sigaction failed to read handler" );
3328
- }
3329
- ~RestoreSignalHandlerScope () {
3330
- int signal_err = ::sigaction (m_signal_code, &m_prev_handler, nullptr );
3331
- lldbassert (signal_err == 0 && " sigaction failed to restore old handler" );
3332
- }
3333
- };
3334
- } // namespace
3335
-
3336
3296
void ScriptInterpreterPythonImpl::InitializePrivate () {
3337
3297
if (g_initialized)
3338
3298
return ;
@@ -3368,25 +3328,6 @@ void ScriptInterpreterPythonImpl::InitializePrivate() {
3368
3328
" lldb.embedded_interpreter; from "
3369
3329
" lldb.embedded_interpreter import run_python_interpreter; "
3370
3330
" from lldb.embedded_interpreter import run_one_line" );
3371
-
3372
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
3373
- // Python will not just overwrite its internal SIGINT handler but also the
3374
- // one from the process. Backup the current SIGINT handler to prevent that
3375
- // Python deletes it.
3376
- RestoreSignalHandlerScope save_sigint (SIGINT);
3377
-
3378
- // Setup a default SIGINT signal handler that works the same way as the
3379
- // normal Python REPL signal handler which raises a KeyboardInterrupt.
3380
- // Also make sure to not pollute the user's REPL with the signal module nor
3381
- // our utility function.
3382
- PyRun_SimpleString (" def lldb_setup_sigint_handler():\n "
3383
- " import signal;\n "
3384
- " def signal_handler(sig, frame):\n "
3385
- " raise KeyboardInterrupt()\n "
3386
- " signal.signal(signal.SIGINT, signal_handler);\n "
3387
- " lldb_setup_sigint_handler();\n "
3388
- " del lldb_setup_sigint_handler\n " );
3389
- #endif
3390
3331
}
3391
3332
3392
3333
void ScriptInterpreterPythonImpl::AddToSysPath (AddLocation location,
0 commit comments