@@ -330,8 +330,9 @@ The execution starts when one of the generator's methods is called. At that
330330time, the execution proceeds to the first yield expression, where it is
331331suspended again, returning the value of :token: `expression_list ` to the generator's
332332caller. By suspended, we mean that all local state is retained, including the
333- current bindings of local variables, the instruction pointer, and the internal
334- evaluation stack. When the execution is resumed by calling one of the
333+ current bindings of local variables, the instruction pointer, the internal
334+ evaluation stack, and the state of any exception handling. When the execution
335+ is resumed by calling one of the
335336generator's methods, the function can proceed exactly as if the yield expression
336337were just another external call. The value of the yield expression after
337338resuming depends on the method which resumed the execution. If
@@ -348,8 +349,8 @@ suspended. The only difference is that a generator function cannot control
348349where the execution should continue after it yields; the control is always
349350transferred to the generator's caller.
350351
351- Yield expressions are allowed in the :keyword: `try ` clause of a :keyword: ` try `
352- ... :keyword: ` finally ` construct. If the generator is not resumed before it is
352+ Yield expressions are allowed anywhere in a :keyword: `try ` construct. If the
353+ generator is not resumed before it is
353354finalized (by reaching a zero reference count or by being garbage collected),
354355the generator-iterator's :meth: `~generator.close ` method will be called,
355356allowing any pending :keyword: `finally ` clauses to execute.
0 commit comments