mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -2622,7 +2622,7 @@ exception_event_teardown(int err, PyObject *exc) {
|
|||
}
|
||||
else {
|
||||
assert(PyErr_Occurred());
|
||||
Py_DECREF(exc);
|
||||
Py_XDECREF(exc);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -2712,15 +2712,18 @@ _PyMonitoring_FirePyUnwindEvent(PyMonitoringState *state, PyObject *codelike, in
|
|||
}
|
||||
|
||||
int
|
||||
_PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
|
||||
_PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *value)
|
||||
{
|
||||
int event = PY_MONITORING_EVENT_STOP_ITERATION;
|
||||
assert(state->active);
|
||||
assert(!PyErr_Occurred());
|
||||
PyErr_SetObject(PyExc_StopIteration, value);
|
||||
PyObject *exc;
|
||||
if (exception_event_setup(&exc, event) < 0) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *args[4] = { NULL, NULL, NULL, exc };
|
||||
int err = capi_call_instrumentation(state, codelike, offset, args, 3, event);
|
||||
return exception_event_teardown(err, exc);
|
||||
Py_DECREF(exc);
|
||||
return exception_event_teardown(err, NULL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue