]> granicus.if.org Git - python/commitdiff
[Bug #1616726] Fix description of generator.close(); if you raise some random excepti...
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 18 Dec 2006 17:22:07 +0000 (17:22 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 18 Dec 2006 17:22:07 +0000 (17:22 +0000)
Doc/whatsnew/whatsnew25.tex

index aa066d7c03505011ccdc8f188a9ccc3b3dd7d12a..99618e68adb453020c4a9a3823d0b42f94977e79 100644 (file)
@@ -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