diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-05-04 13:17:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 13:17:40 (GMT) |
commit | 8655521de8760e8a695bcce92937800c079ea2b2 (patch) | |
tree | b76a3fa4f7e578a458d1263017011e5c0c9b5da7 /Doc/tutorial | |
parent | 31debfa524a9522a02adc66eb00f0009d7413c8c (diff) | |
download | cpython-8655521de8760e8a695bcce92937800c079ea2b2.zip cpython-8655521de8760e8a695bcce92937800c079ea2b2.tar.gz cpython-8655521de8760e8a695bcce92937800c079ea2b2.tar.bz2 |
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 a0b9915a8be98427432e13d8eb2207a8b9824179)
Co-authored-by: Roberto Hueso <robertohueso96@gmail.com>
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/errors.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst index 25bb4fc..cd5fc87 100644 --- a/Doc/tutorial/errors.rst +++ b/Doc/tutorial/errors.rst @@ -405,6 +405,10 @@ points discuss more complex cases when an exception occurs: or :keyword:`!else` clause. Again, the exception is re-raised after the :keyword:`!finally` clause has been executed. +* If the :keyword:`!finally` clause executes a :keyword:`break`, + :keyword:`continue` or :keyword:`return` statement, exceptions are not + re-raised. + * If the :keyword:`!try` statement reaches a :keyword:`break`, :keyword:`continue` or :keyword:`return` statement, the :keyword:`!finally` clause will execute just prior to the |