Clarify what happens on g.throw(StopIteration).

This commit is contained in:
Guido van Rossum 2014-11-25 10:07:35 -08:00
parent 70ca01847a
commit 67adddea25
1 changed files with 6 additions and 0 deletions

View File

@ -72,6 +72,12 @@ again. The answer is that it from this point on it will raise
``StopIteration`` -- the behavior is the same as when any other
exception was raised by the generator.
Another logical consequence of the proposal: if somone uses
``g.throw(StopIteration)`` to throw a ``StopIteration`` exception into
a generator, if the generator doesn't catch it (which it could do
using a ``try/except`` around the ``yield``), it will be transformed
into ``RuntimeError``.
Consequences for existing code
==============================