Skip to content

Commit 55554fd

Browse files
authored
[3.13] GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122419)
(cherry picked from commit 15d4cd0)
1 parent 56340ee commit 55554fd

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func
255255
PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs);
256256
PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys);
257257
PyAPI_FUNC(int) _PyEval_UnpackIterable(PyThreadState *tstate, PyObject *v, int argcnt, int argcntafter, PyObject **sp);
258+
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
258259
PyAPI_FUNC(void) _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame);
259260

260261

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an issue in JIT builds that prevented some :keyword:`for` loops from
2+
correctly firing :monitoring-event:`RAISE` monitoring events.

Python/bytecodes.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ dummy_func(
10371037
if (retval == NULL) {
10381038
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
10391039
) {
1040-
monitor_raise(tstate, frame, this_instr);
1040+
_PyEval_MonitorRaise(tstate, frame, this_instr);
10411041
}
10421042
if (_PyGen_FetchStopIterationValue(&retval) == 0) {
10431043
assert(retval != NULL);
@@ -2603,7 +2603,7 @@ dummy_func(
26032603
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
26042604
ERROR_NO_POP();
26052605
}
2606-
monitor_raise(tstate, frame, this_instr);
2606+
_PyEval_MonitorRaise(tstate, frame, this_instr);
26072607
_PyErr_Clear(tstate);
26082608
}
26092609
/* iterator ended normally */
@@ -2626,6 +2626,7 @@ dummy_func(
26262626
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
26272627
ERROR_NO_POP();
26282628
}
2629+
_PyEval_MonitorRaise(tstate, frame, frame->instr_ptr);
26292630
_PyErr_Clear(tstate);
26302631
}
26312632
/* iterator ended normally */
@@ -2650,7 +2651,7 @@ dummy_func(
26502651
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
26512652
ERROR_NO_POP();
26522653
}
2653-
monitor_raise(tstate, frame, this_instr);
2654+
_PyEval_MonitorRaise(tstate, frame, this_instr);
26542655
_PyErr_Clear(tstate);
26552656
}
26562657
/* iterator ended normally */

Python/ceval.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, _PyInterpreterFrame *skip
223223

224224
#endif
225225

226-
static void monitor_raise(PyThreadState *tstate,
227-
_PyInterpreterFrame *frame,
228-
_Py_CODEUNIT *instr);
229226
static void monitor_reraise(PyThreadState *tstate,
230227
_PyInterpreterFrame *frame,
231228
_Py_CODEUNIT *instr);
@@ -873,7 +870,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
873870
PyTraceBack_Here(f);
874871
}
875872
}
876-
monitor_raise(tstate, frame, next_instr-1);
873+
_PyEval_MonitorRaise(tstate, frame, next_instr-1);
877874
exception_unwind:
878875
{
879876
/* We can't use frame->instr_ptr here, as RERAISE may have set it */
@@ -2184,8 +2181,8 @@ no_tools_for_local_event(PyThreadState *tstate, _PyInterpreterFrame *frame, int
21842181
}
21852182
}
21862183

2187-
static void
2188-
monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame,
2184+
void
2185+
_PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame,
21892186
_Py_CODEUNIT *instr)
21902187
{
21912188
if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_RAISE)) {

Python/executor_cases.c.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy