summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorvivodi <103735539+vivodi@users.noreply.github.com>2024-11-11 06:47:56 (GMT)
committerGitHub <noreply@github.com>2024-11-11 06:47:56 (GMT)
commit25257d61cfccc3b4189f96390a5c4db73fd5302c (patch)
tree91a4e7387a32784cecac66bd89ddb442d0c0c3e0 /Doc
parent5c488caeb858690a696bc9f74fc74a274a3aa51c (diff)
downloadcpython-25257d61cfccc3b4189f96390a5c4db73fd5302c.zip
cpython-25257d61cfccc3b4189f96390a5c4db73fd5302c.tar.gz
cpython-25257d61cfccc3b4189f96390a5c4db73fd5302c.tar.bz2
gh-126664: Use `else` instead of `finally` in "The with statement" documentation. (GH-126665)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/compound_stmts.rst7
1 files changed, 2 insertions, 5 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 1b1e9f4..e73ce44 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::