Skip to content

Commit

Permalink
[3.13] pythonGH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (py…
Browse files Browse the repository at this point in the history
…thonGH-122419)

(cherry picked from commit 15d4cd0)
  • Loading branch information
brandtbucher authored Jul 29, 2024
1 parent 56340ee commit 55554fd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func
PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs);
PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys);
PyAPI_FUNC(int) _PyEval_UnpackIterable(PyThreadState *tstate, PyObject *v, int argcnt, int argcntafter, PyObject **sp);
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
PyAPI_FUNC(void) _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame);


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an issue in JIT builds that prevented some :keyword:`for` loops from
correctly firing :monitoring-event:`RAISE` monitoring events.
7 changes: 4 additions & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ dummy_func(
if (retval == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
) {
monitor_raise(tstate, frame, this_instr);
_PyEval_MonitorRaise(tstate, frame, this_instr);
}
if (_PyGen_FetchStopIterationValue(&retval) == 0) {
assert(retval != NULL);
Expand Down Expand Up @@ -2603,7 +2603,7 @@ dummy_func(
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
ERROR_NO_POP();
}
monitor_raise(tstate, frame, this_instr);
_PyEval_MonitorRaise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
Expand All @@ -2626,6 +2626,7 @@ dummy_func(
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
ERROR_NO_POP();
}
_PyEval_MonitorRaise(tstate, frame, frame->instr_ptr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
Expand All @@ -2650,7 +2651,7 @@ dummy_func(
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
ERROR_NO_POP();
}
monitor_raise(tstate, frame, this_instr);
_PyEval_MonitorRaise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
Expand Down
9 changes: 3 additions & 6 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, _PyInterpreterFrame *skip

#endif

static void monitor_raise(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr);
static void monitor_reraise(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr);
Expand Down Expand Up @@ -873,7 +870,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
PyTraceBack_Here(f);
}
}
monitor_raise(tstate, frame, next_instr-1);
_PyEval_MonitorRaise(tstate, frame, next_instr-1);
exception_unwind:
{
/* We can't use frame->instr_ptr here, as RERAISE may have set it */
Expand Down Expand Up @@ -2184,8 +2181,8 @@ no_tools_for_local_event(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}
}

static void
monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame,
void
_PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_RAISE)) {
Expand Down
1 change: 1 addition & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55554fd

Please sign in to comment.