diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-24 10:18:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 10:18:13 (GMT) |
commit | c864efba25465eb6a4fff7e0a6df80a9ba449370 (patch) | |
tree | d4c9968b1ac36ac938a4b595d55534ea7f2ac5ea /Python/bytecodes.c | |
parent | e27e36922ee9fa970d3d8e602ac7eeb442ca530a (diff) | |
download | cpython-c864efba25465eb6a4fff7e0a6df80a9ba449370.zip cpython-c864efba25465eb6a4fff7e0a6df80a9ba449370.tar.gz cpython-c864efba25465eb6a4fff7e0a6df80a9ba449370.tar.bz2 |
[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 6e9863d7a3516cc76d6ce13923b15620499f3855)
---------
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 55eda97..434eb80 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -292,11 +292,9 @@ dummy_func( /* 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)) { ERROR_NO_POP(); } - PyErr_SetRaisedException(NULL); } DECREF_INPUTS(); } @@ -307,11 +305,9 @@ dummy_func( tier1 inst(INSTRUMENTED_END_SEND, (receiver, value -- value)) { 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)) { ERROR_NO_POP(); } - PyErr_SetRaisedException(NULL); } Py_DECREF(receiver); } |