[Python-checkins] peps: Clarify what happens on g.throw(StopIteration).

guido.van.rossum python-checkins at python.org
Tue Nov 25 19:07:53 CET 2014


https://hg.python.org/peps/rev/2da36288f80b
changeset:   5615:2da36288f80b
user:        Guido van Rossum <guido at python.org>
date:        Tue Nov 25 10:07:35 2014 -0800
summary:
  Clarify what happens on g.throw(StopIteration).

files:
  pep-0479.txt |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/pep-0479.txt b/pep-0479.txt
--- a/pep-0479.txt
+++ b/pep-0479.txt
@@ -72,6 +72,12 @@
 ``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
 ==============================

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list