mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (#119216)
This commit is contained in:
parent
b64182550f
commit
6e9863d7a3
10 changed files with 60 additions and 35 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue