summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPhillip J. Eby <pje@telecommunity.com>2006-03-25 00:46:43 (GMT)
committerPhillip J. Eby <pje@telecommunity.com>2006-03-25 00:46:43 (GMT)
commit1a9fac09377b1da9e86fd4fbb80257b49623d984 (patch)
treea53cf12831da915f80bd454d1489122f73c921f1 /Doc
parent6edd2586082f62a5ac61af5acab77b63919faa47 (diff)
downloadcpython-1a9fac09377b1da9e86fd4fbb80257b49623d984.zip
cpython-1a9fac09377b1da9e86fd4fbb80257b49623d984.tar.gz
cpython-1a9fac09377b1da9e86fd4fbb80257b49623d984.tar.bz2
Yield is now allowed in try-finally, so update docs accordingly
Diffstat (limited to 'Doc')
-rw-r--r--Doc/ref/ref6.tex16
1 files changed, 11 insertions, 5 deletions
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index d1d23ac..1eb1258 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -488,11 +488,12 @@ enough information is saved so that the next time \method{next()} is
invoked, the function can proceed exactly as if the \keyword{yield}
statement were just another external call.
-The \keyword{yield} statement is not allowed in the \keyword{try}
-clause of a \keyword{try} ...\ \keyword{finally} construct. The
-difficulty is that there's no guarantee the generator will ever be
-resumed, hence no guarantee that the \keyword{finally} block will ever
-get executed.
+As of Python version 2.5, the \keyword{yield} statement is now
+allowed in the \keyword{try} clause of a \keyword{try} ...\
+\keyword{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 \method{close()} method will be
+called, allowing any pending \keyword{finally} clauses to execute.
\begin{notice}
In Python 2.2, the \keyword{yield} statement is only allowed
@@ -510,6 +511,11 @@ from __future__ import generators
\seepep{0255}{Simple Generators}
{The proposal for adding generators and the \keyword{yield}
statement to Python.}
+
+ \seepep{0342}{Coroutines via Enhanced Generators}
+ {The proposal that, among other generator enhancements,
+ proposed allowing \keyword{yield} to appear inside a
+ \keyword{try} ... \keyword{finally} block.}
\end{seealso}