[issue12704] Language References does not specify exception raised by final yield()
report at bugs.python.org
Sat Aug 6 20:12:27 CEST 2011
New submission from Nikolaus Rath <Nikolaus at rath.org>:
"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
nosy: Nikratio, docs at python
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>
More information about the Python-bugs-list