summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2015-01-14 22:25:27 -0800
committerEthan Furman <ethan@stoneleaf.us>2015-01-14 22:25:27 -0800
commit4adc857d93f61b88cea64872882e0a8fb4ce8047 (patch)
tree64de5b0f0f54d53c4e5a3207509b2e6a6d1ffac8 /Doc
parent6235446701271c554a9c1f7f7f59a9faf2c59452 (diff)
downloadcpython-4adc857d93f61b88cea64872882e0a8fb4ce8047.tar.gz
Issue22988: clarify yield and exception blocks
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/expressions.rst9
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 9fc5f4d7b7..d0682cae53 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -330,8 +330,9 @@ The execution starts when one of the generator's methods is called. At that
time, the execution proceeds to the first yield expression, where it is
suspended again, returning the value of :token:`expression_list` to the generator's
caller. By suspended, we mean that all local state is retained, including the
-current bindings of local variables, the instruction pointer, and the internal
-evaluation stack. When the execution is resumed by calling one of the
+current bindings of local variables, the instruction pointer, the internal
+evaluation stack, and the state of any exception handling. When the execution
+is resumed by calling one of the
generator's methods, the function can proceed exactly as if the yield expression
were just another external call. The value of the yield expression after
resuming depends on the method which resumed the execution. If
@@ -348,8 +349,8 @@ suspended. The only difference is that a generator function cannot control
where the execution should continue after it yields; the control is always
transferred to the generator's caller.
-Yield expressions are allowed in the :keyword:`try` clause of a :keyword:`try`
-... :keyword:`finally` construct. If the generator is not resumed before it is
+Yield expressions are allowed anywhere in a :keyword:`try` construct. If the
+generator is not resumed before it is
finalized (by reaching a zero reference count or by being garbage collected),
the generator-iterator's :meth:`~generator.close` method will be called,
allowing any pending :keyword:`finally` clauses to execute.