https://github.com/python/cpython/commit/fb82e10ce4a5f5b08ed769078f8a3ed51456a06c
commit: fb82e10ce4a5f5b08ed769078f8a3ed51456a06c
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: gpshead <[email protected]>
date: 2024-11-11T06:57:15Z
summary:

[3.12] gh-126664: Use `else` instead of `finally` in "The with statement" 
documentation. (GH-126665) (#126671)

gh-126664: Use `else` instead of `finally` in "The with statement" 
documentation. (GH-126665)
(cherry picked from commit 25257d61cfccc3b4189f96390a5c4db73fd5302c)

Co-authored-by: vivodi <[email protected]>

files:
M Doc/reference/compound_stmts.rst

diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 81399901c9cf46..ddb1337f949e70 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -534,18 +534,15 @@ is semantically equivalent to::
     enter = type(manager).__enter__
     exit = type(manager).__exit__
     value = enter(manager)
-    hit_except = False
 
     try:
         TARGET = value
         SUITE
     except:
-        hit_except = True
         if not exit(manager, *sys.exc_info()):
             raise
-    finally:
-        if not hit_except:
-            exit(manager, None, None, None)
+    else:
+        exit(manager, None, None, None)
 
 With more than one item, the context managers are processed as if multiple
 :keyword:`with` statements were nested::

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to