gh-131670: Fix crash in anext() when __anext__ is sync and raises (#131682)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
sobolevn 2025-03-24 22:00:48 +03:00 committed by GitHub
parent 5fef4ff9ed
commit 929afd1d6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View file

@ -1837,6 +1837,9 @@ builtin_anext_impl(PyObject *module, PyObject *aiterator,
}
awaitable = (*t->tp_as_async->am_anext)(aiterator);
if (awaitable == NULL) {
return NULL;
}
if (default_value == NULL) {
return awaitable;
}