mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-128078: Clear exception in anext
before calling _PyGen_SetStopIterationValue
(GH-128780) (#128785)
gh-128078: Clear exception in `anext` before calling `_PyGen_SetStopIterationValue` (GH-128780)
(cherry picked from commit 76ffaef729
)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
632745ade1
commit
66d0636025
4 changed files with 22 additions and 0 deletions
|
@ -384,6 +384,7 @@ anextawaitable_iternext(anextawaitableobject *obj)
|
|||
return result;
|
||||
}
|
||||
if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration)) {
|
||||
PyErr_Clear();
|
||||
_PyGen_SetStopIterationValue(obj->default_value);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -407,6 +408,7 @@ anextawaitable_proxy(anextawaitableobject *obj, char *meth, PyObject *arg) {
|
|||
* exception we replace it with a `StopIteration(default)`, as if
|
||||
* it was the return value of `__anext__()` coroutine.
|
||||
*/
|
||||
PyErr_Clear();
|
||||
_PyGen_SetStopIterationValue(obj->default_value);
|
||||
}
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue