mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.13] gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216) (#119497)
* gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216)
(cherry picked from commit 6e9863d7a3
)
---------
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
e27e36922e
commit
c864efba25
10 changed files with 61 additions and 35 deletions
8
Python/generated_cases.c.h
generated
8
Python/generated_cases.c.h
generated
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue