[docs] [issue12704] Language References does not specify exception raised by final yield()

Nikolaus Rath report at bugs.python.org
Sat Aug 6 20:12:27 CEST 2011


New submission from Nikolaus Rath <Nikolaus at rath.org>:

>From http://docs.python.org/reference/simple_stmts.html#the-yield-statement:

"As of Python version 2.5, the yield statement is now allowed in the try clause of a try ... finally 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 close() method will be called, allowing any pending finally clauses to execute."

This strongly suggests that the last-executed yield statement will raise an exception if the generator is closed. If this is the case, it would be great if the documentation could be extended to say what exception is raised.

If this is not the case, it would be great if whatever magic is happening could be documented as well.

----------
assignee: docs at python
components: Documentation
messages: 141724
nosy: Nikratio, docs at python
priority: normal
severity: normal
status: open
title: Language References does not specify exception raised by final yield()
type: feature request
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12704>
_______________________________________


More information about the docs mailing list