You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
anext(A(), default) crashes when StopAsyncIteration is raised by a synchronous __anext__ #131670
There is no crash with anext(A()) or when directly calling __anext__(). Or when __anext__ is declared with async def, it's fine. Or when __anext__() doesn't raise, it's also fine.
NB: I haven't bisected the change but it might be related to what I wrote in 76ffaef.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Output from running 'python -VV' on the command line:
Activity
picnixz commentedon Mar 24, 2025
cc @kumaraditya303
sobolevn commentedon Mar 24, 2025
This happens because
awaitablehere isNULL:cpython/Python/bltinmodule.c
Lines 1839 to 1842 in d16f455
Looks like simple
if (awaitable == NULL)check might solve the issue:sobolevn commentedon Mar 24, 2025
And not just
StopAsyncIteration, but any exception really.picnixz commentedon Mar 24, 2025
Yes, that's what I observed (note that I actually found this bug because it was a typo I made when creating tests for another PR...)
pythongh-131670: Fix crash in `anext()` when `__anext__` is sync and …
gh-131670: Fix crash in `anext()` when `__anext__` is sync and raises (…
pythongh-131670: Fix crash in `anext()` when `__anext__` is sync and …
pythongh-131670: Fix crash in `anext()` when `__anext__` is sync and …
[3.12] gh-131670: Fix crash in `anext()` when `__anext__` is sync and…
picnixz commentedon Mar 24, 2025
Thanks for the quick fix Nikita!
[3.13] gh-131670: Fix crash in `anext()` when `__anext__` is sync and…
pythongh-131670: Fix crash in `anext()` when `__anext__` is sync and …