mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
[3.13] gh-126664: revert: Use else instead of finally in docs explaining "with" (GH-128169) (#128170)
gh-126664: revert: Use `else` instead of `finally` in docs explaining "with" (GH-128169) Revert "gh-126664: Use `else` instead of `finally` in "The with statement" documentation. (GH-126665)" This reverts commit25257d61cf. (cherry picked from commit228f275737) Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
875e49fb63
commit
32adae1a10
1 changed files with 5 additions and 2 deletions
|
|
@ -534,15 +534,18 @@ 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
|
||||
else:
|
||||
exit(manager, None, None, None)
|
||||
finally:
|
||||
if not hit_except:
|
||||
exit(manager, None, None, None)
|
||||
|
||||
With more than one item, the context managers are processed as if multiple
|
||||
:keyword:`with` statements were nested::
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue