summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-12-18 17:22:07 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-12-18 17:22:07 (GMT)
commit0693ae147c5a1abfef58e7d42170bca3a3df265c (patch)
treed62a857b197f5bfb6e590d3cbe12734e58e4d469
parentff5c229ef2ebe5e1bc5d5ffa9bfaa038eda862a0 (diff)
downloadcpython-0693ae147c5a1abfef58e7d42170bca3a3df265c.zip
cpython-0693ae147c5a1abfef58e7d42170bca3a3df265c.tar.gz
cpython-0693ae147c5a1abfef58e7d42170bca3a3df265c.tar.bz2
[Bug #1616726] Fix description of generator.close(); if you raise some random exception, the exception is raised and doesn't trigger a RuntimeError
-rw-r--r--Doc/whatsnew/whatsnew25.tex15
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index aa066d7..99618e6 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -556,13 +556,14 @@ generators:
where the generator's execution is paused.
\item \method{close()} raises a new \exception{GeneratorExit}
- exception inside the generator to terminate the iteration.
- On receiving this
- exception, the generator's code must either raise
- \exception{GeneratorExit} or \exception{StopIteration}; catching the
- exception and doing anything else is illegal and will trigger
- a \exception{RuntimeError}. \method{close()} will also be called by
- Python's garbage collector when the generator is garbage-collected.
+ exception inside the generator to terminate the iteration. On
+ receiving this exception, the generator's code must either raise
+ \exception{GeneratorExit} or \exception{StopIteration}. Catching
+ the \exception{GeneratorExit} exception and returning a value is
+ illegal and will trigger a \exception{RuntimeError}; if the function
+ raises some other exception, that exception is propagated to the
+ caller. \method{close()} will also be called by Python's garbage
+ collector when the generator is garbage-collected.
If you need to run cleanup code when a \exception{GeneratorExit} occurs,
I suggest using a \code{try: ... finally:} suite instead of