Skip to content

Commit 8655521

Browse files
bpo-32822: Add finally with return/break/continue to the tutorial (GH-25600) (#25893)
This documents in the tutorial docs the behavior of a finally clause in case it should re-raise an exception but contains a return/break/continue statement. (cherry picked from commit a0b9915) Co-authored-by: Roberto Hueso <[email protected]>
1 parent 31debfa commit 8655521

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Doc/tutorial/errors.rst

+4
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ points discuss more complex cases when an exception occurs:
405405
or :keyword:`!else` clause. Again, the exception is re-raised after
406406
the :keyword:`!finally` clause has been executed.
407407

408+
* If the :keyword:`!finally` clause executes a :keyword:`break`,
409+
:keyword:`continue` or :keyword:`return` statement, exceptions are not
410+
re-raised.
411+
408412
* If the :keyword:`!try` statement reaches a :keyword:`break`,
409413
:keyword:`continue` or :keyword:`return` statement, the
410414
:keyword:`!finally` clause will execute just prior to the

Misc/ACKS

+1
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ Christian Hudon
778778
Benoît Hudson
779779
Lawrence Hudson
780780
Michael Hudson
781+
Roberto Hueso Gomez
781782
Jim Hugunin
782783
Greg Humphreys
783784
Chris Hunt

0 commit comments

Comments
 (0)