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
gh-143055: Delegate to subiterators when unpacking in generator expressions
Unpacking a sub-iterable with `*` in a generator expression (PEP 798) now
delegates to the sub-iterable using `yield from` semantics, so that values
sent with send() and exceptions thrown with throw() are forwarded to the
sub-iterator (and the sub-iterator's return value is discarded).
This also works in asynchronous generator expressions. Since `*` unpacking
is synchronous, the sub-iterable is a sync iterable, but it is delegated to
from inside an async generator, so each produced value must be wrapped as an
async-generator value -- including values produced in response to asend() and
athrow(). A new internal `_PyAsyncGenUnpack` iterator (constructed via the
new INTRINSIC_ASYNC_GEN_UNPACK intrinsic) wraps the sync iterable so that
asend(), athrow() and aclose() are forwarded to the sub-iterator's send(),
throw() and close().
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments