]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-32822: Add finally with return/break/continue to the tutorial (GH-25600) (#25890)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 May 2021 13:17:21 +0000 (06:17 -0700)
committerGitHub <noreply@github.com>
Tue, 4 May 2021 13:17:21 +0000 (15:17 +0200)
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>
Doc/tutorial/errors.rst
Misc/ACKS

index f72da5c3404484475888153a3afba946d63fb55e..7bb0b4898990739b3e8ec3d5a4ef633c36ca8fdd 100644 (file)
@@ -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
index 389c8e133f71bd468a3fd9a65dcb415c5e305a35..be45273362476e0bcc9c75b36135ddc229e3b80f 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -766,6 +766,7 @@ Christian Hudon
 BenoĆ®t Hudson
 Lawrence Hudson
 Michael Hudson
+Roberto Hueso Gomez
 Jim Hugunin
 Greg Humphreys
 Chris Hunt