summaryrefslogtreecommitdiffstats
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-05-21 20:42:51 (GMT)
committerGitHub <noreply@github.com>2024-05-21 20:42:51 (GMT)
commit6e9863d7a3516cc76d6ce13923b15620499f3855 (patch)
tree06894f78bbed5cb71c0180e1f9355939a622d7a4 /Python/generated_cases.c.h
parentb64182550f73e556344bd754d32e3be5d22a74e1 (diff)
downloadcpython-6e9863d7a3516cc76d6ce13923b15620499f3855.zip
cpython-6e9863d7a3516cc76d6ce13923b15620499f3855.tar.gz
cpython-6e9863d7a3516cc76d6ce13923b15620499f3855.tar.bz2
gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (#119216)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 8b81122..96161c5 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3260,11 +3260,9 @@
/* Need to create a fake StopIteration error here,
* to conform to PEP 380 */
if (PyGen_Check(receiver)) {
- PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, this_instr)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr, value)) {
goto error;
}
- PyErr_SetRaisedException(NULL);
}
Py_DECREF(value);
stack_pointer += -1;
@@ -3281,11 +3279,9 @@
value = stack_pointer[-1];
receiver = stack_pointer[-2];
if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) {
- PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, this_instr)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr, value)) {
goto error;
}
- PyErr_SetRaisedException(NULL);
}
Py_DECREF(receiver);
stack_pointer[-2] = value;