__exit__ is always called with 3 args.

This commit is contained in:
Guido van Rossum 2005-05-14 17:36:15 +00:00
parent 9dccdb93a1
commit cea61e0c0a
1 changed files with 7 additions and 8 deletions

View File

@ -158,7 +158,7 @@ Specification
The translation of the above statement is:
abc = EXPR
exc = () # Or (None, None, None) ?
exc = (None, None, None)
try:
try:
VAR = abc.__enter__()
@ -167,7 +167,7 @@ Specification
exc = sys.exc_info()
raise
finally:
abc.__exit__(exc)
abc.__exit__(*exc)
Here, the variables 'abc' and 'exc' are internal variables and not
accessible to the user; they will most likely be implemented as
@ -178,12 +178,11 @@ Specification
The calling convention for abc.__exit__() is: as follows. If the
finally-suite was reached through normal completion of BLOCK or
through a non-local goto (a break, continue or return statement
in BLOCK), abc.__exit__() is called without arguments (or perhaps
with three None arguments?). If the finally-suite was reached
through an exception raised in BLOCK, abc.__exit__() is called
with three arguments representing the exception type, value, and
traceback.
through a non-local goto (a break, continue or return statement in
BLOCK), abc.__exit__() is called with three None arguments. If
the finally-suite was reached through an exception raised in
BLOCK, abc.__exit__() is called with three arguments representing
the exception type, value, and traceback.
The motivation for this API to __exit__(), as opposed to the
argument-less __exit__() from PEP 310, was given by the