summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2024-07-29 21:51:19 (GMT)
committerGitHub <noreply@github.com>2024-07-29 21:51:19 (GMT)
commit55554fd2157cbf52caf6c01a64d81b948c41e82c (patch)
tree92a84fe2fb2f371cf472e434a162510c06f9c54d
parent56340ee8b17f703d6add3e8bb7c0f85af88a5548 (diff)
downloadcpython-55554fd2157cbf52caf6c01a64d81b948c41e82c.zip
cpython-55554fd2157cbf52caf6c01a64d81b948c41e82c.tar.gz
cpython-55554fd2157cbf52caf6c01a64d81b948c41e82c.tar.bz2
[3.13] GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122419)
(cherry picked from commit 15d4cd096758ca089c6bd6ed808c34cca676d9bb)
-rw-r--r--Include/internal/pycore_ceval.h1
-rw-r--r--Misc/NEWS.d/next/Core_and_Builtins/2024-07-29-10-55-46.gh-issue-116090.p1MhU0.rst2
-rw-r--r--Python/bytecodes.c7
-rw-r--r--Python/ceval.c9
-rw-r--r--Python/executor_cases.c.h1
-rw-r--r--Python/generated_cases.c.h6
6 files changed, 14 insertions, 12 deletions
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 26ede31..043f595 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -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);
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-07-29-10-55-46.gh-issue-116090.p1MhU0.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-29-10-55-46.gh-issue-116090.p1MhU0.rst
new file mode 100644
index 0000000..6efb620
--- /dev/null
+++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-29-10-55-46.gh-issue-116090.p1MhU0.rst
@@ -0,0 +1,2 @@
+Fix an issue in JIT builds that prevented some :keyword:`for` loops from
+correctly firing :monitoring-event:`RAISE` monitoring events.
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index a6e9a73..1a41c7e 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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);
@@ -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 */
@@ -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 */
@@ -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 */
diff --git a/Python/ceval.c b/Python/ceval.c
index bbd8a24..866328e 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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);
@@ -873,7 +870,7 @@ error:
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 */
@@ -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)) {
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 8080d20..7859269 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2635,6 +2635,7 @@
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
JUMP_TO_ERROR();
}
+ _PyEval_MonitorRaise(tstate, frame, frame->instr_ptr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index ace91a3..38a4c40 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -2787,7 +2787,7 @@
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, this_instr);
+ _PyEval_MonitorRaise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
@@ -3307,7 +3307,7 @@
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, this_instr);
+ _PyEval_MonitorRaise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
@@ -5317,7 +5317,7 @@
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);