]> granicus.if.org Git - python/commitdiff
Merge #15355: Mention already-executing Exception in generator docs.
authorR David Murray <rdmurray@bitdance.com>
Sat, 18 Aug 2012 00:49:24 +0000 (20:49 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 18 Aug 2012 00:49:24 +0000 (20:49 -0400)
Patch by Chris Jerdonek.

1  2 
Doc/reference/expressions.rst

index 9624b601b97d0de7878ca828e4daa60426c2e138,72ad95ea3178dc608ccf84abee0d9ce0bc82583e..a5f376695aa6b00b63a1631a1afa452fbd7c6e87
@@@ -355,30 -352,17 +355,37 @@@ resumed before it is finalized (by reac
  garbage collected), the generator-iterator's :meth:`close` method will be
  called, allowing any pending :keyword:`finally` clauses to execute.
  
 +When ``yield from <expr>`` is used, it treats the supplied expression as
 +a subiterator. All values produced by that subiterator are passed directly
 +to the caller of the current generator's methods. Any values passed in with
 +:meth:`send` and any exceptions passed in with :meth:`throw` are passed to
 +the underlying iterator if it has the appropriate methods. If this is not the
 +case, then :meth:`send` will raise :exc:`AttributeError` or :exc:`TypeError`,
 +while :meth:`throw` will just raise the passed in exception immediately.
 +
 +When the underlying iterator is complete, the :attr:`~StopIteration.value`
 +attribute of the raised :exc:`StopIteration` instance becomes the value of
 +the yield expression. It can be either set explicitly when raising
 +:exc:`StopIteration`, or automatically when the sub-iterator is a generator
 +(by returning a value from the sub-generator).
 +
 +   .. versionchanged:: 3.3
 +      Added ``yield from <expr>`` to delegate control flow to a subiterator
 +
 +The parentheses can be omitted when the :keyword:`yield` expression is the
 +sole expression on the right hand side of an assignment statement.
 +
  .. index:: object: generator
  
- The following generator's methods can be used to control the execution of a
- generator function:
+ Generator-iterator methods
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ This subsection describes the methods of a generator iterator.  They can
+ be used to control the execution of a generator function.
+ Note that calling any of the generator methods below when the generator
+ is already executing raises a :exc:`ValueError` exception.
  
  .. index:: exception: StopIteration