mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
[3.12] GH-106897: Add RERAISE
event to sys.monitoring
. (GH-107291) (GH-107346)
* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
This commit is contained in:
parent
4014869b4b
commit
3b1a4c1842
9 changed files with 1407 additions and 1206 deletions
|
@ -612,7 +612,11 @@ dummy_func(
|
|||
exc = args[0];
|
||||
/* fall through */
|
||||
case 0:
|
||||
ERROR_IF(do_raise(tstate, exc, cause), exception_unwind);
|
||||
if (do_raise(tstate, exc, cause)) {
|
||||
assert(oparg == 0);
|
||||
monitor_reraise(tstate, frame, next_instr-1);
|
||||
goto exception_unwind;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_PyErr_SetString(tstate, PyExc_SystemError,
|
||||
|
@ -944,6 +948,7 @@ dummy_func(
|
|||
assert(exc && PyExceptionInstance_Check(exc));
|
||||
Py_INCREF(exc);
|
||||
_PyErr_SetRaisedException(tstate, exc);
|
||||
monitor_reraise(tstate, frame, next_instr-1);
|
||||
goto exception_unwind;
|
||||
}
|
||||
|
||||
|
@ -955,6 +960,7 @@ dummy_func(
|
|||
else {
|
||||
Py_INCREF(exc);
|
||||
_PyErr_SetRaisedException(tstate, exc);
|
||||
monitor_reraise(tstate, frame, next_instr-1);
|
||||
goto exception_unwind;
|
||||
}
|
||||
}
|
||||
|
@ -969,6 +975,7 @@ dummy_func(
|
|||
}
|
||||
else {
|
||||
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
|
||||
monitor_reraise(tstate, frame, next_instr-1);
|
||||
goto exception_unwind;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,9 @@ lltrace_resume_frame(_PyInterpreterFrame *frame)
|
|||
static void monitor_raise(PyThreadState *tstate,
|
||||
_PyInterpreterFrame *frame,
|
||||
_Py_CODEUNIT *instr);
|
||||
static void monitor_reraise(PyThreadState *tstate,
|
||||
_PyInterpreterFrame *frame,
|
||||
_Py_CODEUNIT *instr);
|
||||
static int monitor_stop_iteration(PyThreadState *tstate,
|
||||
_PyInterpreterFrame *frame,
|
||||
_Py_CODEUNIT *instr);
|
||||
|
@ -923,7 +926,6 @@ error:
|
|||
}
|
||||
}
|
||||
monitor_raise(tstate, frame, next_instr-1);
|
||||
|
||||
exception_unwind:
|
||||
{
|
||||
/* We can't use frame->f_lasti here, as RERAISE may have set it */
|
||||
|
@ -2037,6 +2039,16 @@ monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame,
|
|||
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_RAISE);
|
||||
}
|
||||
|
||||
static void
|
||||
monitor_reraise(PyThreadState *tstate, _PyInterpreterFrame *frame,
|
||||
_Py_CODEUNIT *instr)
|
||||
{
|
||||
if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_RERAISE)) {
|
||||
return;
|
||||
}
|
||||
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_RERAISE);
|
||||
}
|
||||
|
||||
static int
|
||||
monitor_stop_iteration(PyThreadState *tstate, _PyInterpreterFrame *frame,
|
||||
_Py_CODEUNIT *instr)
|
||||
|
|
777
Python/generated_cases.c.h
generated
777
Python/generated_cases.c.h
generated
File diff suppressed because it is too large
Load diff
|
@ -2037,6 +2037,7 @@ static const char *const event_names [] = {
|
|||
[PY_MONITORING_EVENT_C_RETURN] = "C_RETURN",
|
||||
[PY_MONITORING_EVENT_PY_THROW] = "PY_THROW",
|
||||
[PY_MONITORING_EVENT_RAISE] = "RAISE",
|
||||
[PY_MONITORING_EVENT_RERAISE] = "RERAISE",
|
||||
[PY_MONITORING_EVENT_EXCEPTION_HANDLED] = "EXCEPTION_HANDLED",
|
||||
[PY_MONITORING_EVENT_C_RAISE] = "C_RAISE",
|
||||
[PY_MONITORING_EVENT_PY_UNWIND] = "PY_UNWIND",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue