Update types from v3.14.2 by moreal · Pull Request #6833 · RustPython/RustPython
- Add ITERABLE_COROUTINE (0x0100) to CodeFlags in bytecode.rs - Update frame.rs to check for both COROUTINE and ITERABLE_COROUTINE flags when validating 'yield from' on coroutine objects - Remove False and workaround in types.coroutine() now that the flag is supported - Remove @unittest.expectedFailure from test_async_def and test_genfunc Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Generators decorated with @types.coroutine have the CO_ITERABLE_COROUTINE flag set, making them awaitable. The GetAwaitable instruction now properly handles this case instead of only checking for __await__ method. This fixes the "object generator can't be used in 'await' expression" error that occurred with asyncio.sleep(0) which uses @types.coroutine decorated __sleep0() generator internally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Generators decorated with @types.coroutine have the CO_ITERABLE_COROUTINE flag and can be used in await expressions. The PyAnextAwaitable's get_awaitable_iter method was missing this check, causing builtin anext() to fail with "object generator can't be used in 'await' expression" when used with such generators. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
For generators without CO_ITERABLE_COROUTINE flag, try to get __await__ method instead of returning an error immediately. This matches CPython's _PyCoro_GetAwaitableIter behavior which allows generator subclasses that define __await__ to be used in await expressions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
moreal
marked this pull request as ready for review
moreal
marked this pull request as draft
moreal
marked this pull request as ready for review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters