mirror of
https://github.com/python/cpython.git
synced 2026-10-29 19:03:24 +08:00
The iteration stops when the callable raises the specified exception (an exception class or a tuple of exception classes). It is keyword-only and can be used without the stop value. The second parameter of iter() is now named stop_value and can be passed as a keyword argument. aiter() now accepts the same parameters, which it never had before: the callable is called and its result is awaited for every __anext__(). If the callable raises StopIteration (StopAsyncIteration in aiter()) which does not match stop_exception, it is replaced with RuntimeError, as PEP 479 and PEP 525 do for generators. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>