[Python-checkins] peps: Clarify that after raising RuntimeError a generator will raise StopIteration.
python-checkins at python.org
Tue Nov 25 18:45:55 CET 2014
user: Guido van Rossum <guido at python.org>
date: Tue Nov 25 09:24:47 2014 -0800
Clarify that after raising RuntimeError a generator will raise StopIteration.
pep-0479.txt | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/pep-0479.txt b/pep-0479.txt
@@ -57,7 +57,7 @@
This affects the third outcome listed above, without altering any
other effects. Furthermore, it only affects this outcome when the
-exception raised is StopIteration (or a subclass thereof).
+exception raised is ``StopIteration`` (or a subclass thereof).
Note that the proposed replacement happens at the point where the
exception is about to bubble out of the frame, i.e. after any
@@ -66,6 +66,12 @@
not affected (the point being that ``StopIteration`` means that the
generator terminated "normally", i.e. it did not raise an exception).
+A subtle issue is what will happen if the caller, having caught the
+``RuntimeError``, calls the generator object's ``__next__()`` method
+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.
Consequences for existing code
Repository URL: https://hg.python.org/peps
More information about the Python-checkins