diff options
author | Mark Shannon <mark@hotpy.org> | 2023-07-28 09:53:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-28 09:53:33 (GMT) |
commit | 0902afbae29ef88bf9d212a7e11f9f17b6cbdeb5 (patch) | |
tree | eeada04f808fc41bfeb35fb8ac87dd3297c9a037 /Python/ceval.c | |
parent | 3b1a4c18426c78a2fda0d59728bfe9eb92889722 (diff) | |
download | cpython-0902afbae29ef88bf9d212a7e11f9f17b6cbdeb5.zip cpython-0902afbae29ef88bf9d212a7e11f9f17b6cbdeb5.tar.gz cpython-0902afbae29ef88bf9d212a7e11f9f17b6cbdeb5.tar.bz2 |
[3.12] GH-106895: Raise a `ValueError` when attempting to disable events that cannot be disabled. (GH-107337) (GH-107351)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 899f135..27dea27 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -194,7 +194,7 @@ static int monitor_stop_iteration(PyThreadState *tstate, static void monitor_unwind(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); -static void monitor_handled(PyThreadState *tstate, +static int monitor_handled(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *exc); static void monitor_throw(PyThreadState *tstate, @@ -969,7 +969,9 @@ exception_unwind: PyObject *exc = _PyErr_GetRaisedException(tstate); PUSH(exc); JUMPTO(handler); - monitor_handled(tstate, frame, next_instr, exc); + if (monitor_handled(tstate, frame, next_instr, exc) < 0) { + goto exception_unwind; + } /* Resume normal execution */ DISPATCH(); } @@ -2007,6 +2009,7 @@ do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame, PyErr_SetRaisedException(exc); } else { + assert(PyErr_Occurred()); Py_DECREF(exc); } return err; @@ -2071,15 +2074,15 @@ monitor_unwind(PyThreadState *tstate, } -static void +static int monitor_handled(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *exc) { if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_EXCEPTION_HANDLED)) { - return; + return 0; } - _Py_call_instrumentation_arg(tstate, PY_MONITORING_EVENT_EXCEPTION_HANDLED, frame, instr, exc); + return _Py_call_instrumentation_arg(tstate, PY_MONITORING_EVENT_EXCEPTION_HANDLED, frame, instr, exc); } static void |