Clarify the expanded code -- exc is just used as a flag.

This commit is contained in:
Guido van Rossum 2006-02-28 21:05:40 +00:00
parent f038797f00
commit d8e895c878
1 changed files with 5 additions and 3 deletions

View File

@ -228,17 +228,19 @@ Specification: The 'with' Statement
ctx = (EXPR).__context__()
exit = exc.__exit__ # Not calling it yet
value = ctx.__enter__()
exc = (None, None, None)
exc = True
try:
try:
VAR = value # Only if "as VAR" is present
BLOCK
except:
exc = None
# The exceptional case is handled here
exc = False
exit(*sys.exc_info())
finally:
# The normal and non-local-goto cases are handled here
if exc:
exit(*exc)
exit(None, None, None)
Here, the lowercase variables (ctx, exit, value, exc) are internal
variables and not accessible to the user; they will most likely be