Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
69130b3c
Commit
69130b3c
authored
Mar 25, 2006
by
Phillip J. Eby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Yield is now allowed in try-finally, so update docs accordingly
parent
05778a13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
Doc/ref/ref6.tex
Doc/ref/ref6.tex
+11
-5
No files found.
Doc/ref/ref6.tex
View file @
69130b3c
...
...
@@ -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}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment