◐ Shell
clean mode source ↗

Update types from v3.14.2 by moreal · Pull Request #6833 · RustPython/RustPython

Co-Authored-By: CPython Developers <>
- 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 moreal marked this pull request as ready for review

January 22, 2026 10:25

coderabbitai[bot]

@moreal moreal marked this pull request as draft

January 22, 2026 10:34

@youknowone

@moreal moreal marked this pull request as ready for review

January 23, 2026 13:06

youknowone