summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-07-27 14:27:11 (GMT)
committerGitHub <noreply@github.com>2023-07-27 14:27:11 (GMT)
commitc6539b36c163efff3d6ed02b938a6151325f4db7 (patch)
tree628e61ae6907427baf9cf76e9d1a3d78525e6366 /Python/ceval.c
parentd77d973335835bd744be8106010061cb338b0ae1 (diff)
downloadcpython-c6539b36c163efff3d6ed02b938a6151325f4db7.zip
cpython-c6539b36c163efff3d6ed02b938a6151325f4db7.tar.gz
cpython-c6539b36c163efff3d6ed02b938a6151325f4db7.tar.bz2
GH-106895: Raise a `ValueError` when attempting to disable events that cannot be disabled. (GH-107337)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index a5d37c0..c0b37b3 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -193,7 +193,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,
@@ -886,7 +886,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();
}
@@ -1924,6 +1926,7 @@ do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyErr_SetRaisedException(exc);
}
else {
+ assert(PyErr_Occurred());
Py_DECREF(exc);
}
return err;
@@ -1988,15 +1991,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