10000 GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122413) · python/cpython@15d4cd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15d4cd0

Browse files
authored
GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122413)
1 parent 68840e9 commit 15d4cd0

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
@@ -263,6 +263,7 @@ PyAPI_FUNC(PyObject *) _PyEval_ImportFrom(PyThreadState *, PyObject *, PyObject
263263
PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *, _PyInterpreterFrame *, PyObject *, PyObject *, PyObject *);
264264
PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs);
265265
PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys);
266+
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
266267
PyAPI_FUNC(int) _PyEval_UnpackIterableStackRef(PyThreadState *tstate, _PyStackRef v, int argcnt, int argcntafter, _PyStackRef *sp);
267268
PyAPI_FUNC(void) _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame);
268269
PyAPI_FUNC(PyObject **) _PyObjectArray_FromStackRefArray(_PyStackRef *input, Py_ssize_t nargs, PyObject **scratch);
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
@@ -1124,7 +1124,7 @@ dummy_func(
11241124
if (retval_o == NULL) {
11251125
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
11261126
) {
1127-
monitor_raise(tstate, frame, this_instr);
1127+
_PyEval_MonitorRaise(tstate, frame, this_instr);
11281128
}
11291129
if (_PyGen_FetchStopIterationValue(&retval_o) == 0) {
11301130
assert(retval_o != NULL);
@@ -2824,7 +2824,7 @@ dummy_func(
28242824
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
28252825
ERROR_NO_POP();
28262826
}
2827-
monitor_raise(tstate, frame, this_instr);
2827+
_PyEval_MonitorRaise(tstate, frame, this_instr);
28282828
_PyErr_Clear(tstate);
28292829
}
28302830
/* iterator ended normally */
@@ -2849,6 +2849,7 @@ dummy_func(
28492849
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
28502850
ERROR_NO_POP();
28512851
}
2852+
_PyEval_MonitorRaise(tstate, frame, frame->instr_ptr);
28522853
_PyErr_Clear(tstate);
28532854
}
28542855
/* iterator ended normally */
@@ -2875,7 +2876,7 @@ dummy_func(
28752876
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
28762877
ERROR_NO_POP();
28772878
}
2878-
monitor_raise(tstate, frame, this_instr);
2879+
_PyEval_MonitorRaise(tstate, frame, this_instr);
28792880
_PyErr_Clear(tstate);
28802881
}
28812882
/* iterator ended normally */

Python/ceval.c

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

226226
#endif
227227

228-
static void monitor_raise(PyThreadState *tstate,
229-
_PyInterpreterFrame *frame,
230-
_Py_CODEUNIT *instr);
231228
static void monitor_reraise(PyThreadState *tstate,
232229
_PyInterpreterFrame *frame,
233230
_Py_CODEUNIT *instr);
@@ -884,7 +881,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
884881
PyTraceBack_Here(f);
885882
}
886883
}
887-
monitor_raise(tstate, frame, next_instr-1);
884+
_PyEval_MonitorRaise(tstate, frame, next_instr-1);
888885
exception_unwind:
889886
{
890887
/* We can't use frame->instr_ptr here, as RERAISE may have set it */
@@ -2200,8 +2197,8 @@ no_tools_for_local_event(PyThreadState *tstate, _PyInterpreterFrame *frame, int
22002197
}
22012198
}
22022199

2203-
static void
2204-
monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame,
2200+
void
2201+
_PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame,
22052202
_Py_CODEUNIT *instr)
22062203
{
22072204
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)
0