From 59506ca06c54944df1eb25b16623c2a6b8e28c04 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Mon, 1 Dec 2025 14:57:18 +0000 Subject: [PATCH 1/2] Make RESUME monitoring more readable and robust We make the code for the monitoring of PY_START and PY_RESUME events triggered by the RESUME opcode more readable and maintainable by not relying on some obscure logic on the value of oparg that can easily break if the event IDs are ever changed in the future. --- Python/bytecodes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 01cd1e8359815a..8a79b34f88d78b 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -240,7 +240,7 @@ dummy_func( op(_MONITOR_RESUME, (--)) { int err = _Py_call_instrumentation( - tstate, oparg > 0, frame, this_instr); + tstate, oparg == 0 ? PY_MONITORING_EVENT_PY_START : PY_MONITORING_EVENT_PY_RESUME, frame, this_instr); ERROR_IF(err); if (frame->instr_ptr != this_instr) { /* Instrumentation has jumped */ From cff2132cede1bd3a006a5f9f284e5cc8ebec9805 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Mon, 1 Dec 2025 15:15:50 +0000 Subject: [PATCH 2/2] add regen result --- Python/generated_cases.c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 57d5e71144d38c..cf136d2c8c6e29 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -7377,7 +7377,7 @@ { _PyFrame_SetStackPointer(frame, stack_pointer); int err = _Py_call_instrumentation( - tstate, oparg > 0, frame, this_instr); + tstate, oparg == 0 ? PY_MONITORING_EVENT_PY_START : PY_MONITORING_EVENT_PY_RESUME, frame, this_instr); stack_pointer = _PyFrame_GetStackPointer(frame); if (err) { JUMP_TO_LABEL(error);