#11248: look up special methods on type.

This commit is contained in:
Georg Brandl 2011-03-20 21:51:37 +00:00
parent 310d1250c4
commit 8a1e5adb10
1 changed files with 4 additions and 4 deletions

View File

@ -238,8 +238,8 @@ Specification: The 'with' Statement
The translation of the above statement is:
mgr = (EXPR)
exit = mgr.__exit__ # Not calling it yet
value = mgr.__enter__()
exit = type(mgr).__exit__ # Not calling it yet
value = type(mgr).__enter__(mgr)
exc = True
try:
try:
@ -248,13 +248,13 @@ Specification: The 'with' Statement
except:
# The exceptional case is handled here
exc = False
if not exit(*sys.exc_info()):
if not exit(mgr, *sys.exc_info()):
raise
# The exception is swallowed if exit() returns true
finally:
# The normal and non-local-goto cases are handled here
if exc:
exit(None, None, None)
exit(mgr, None, None, None)
Here, the lowercase variables (mgr, exit, value, exc) are internal
variables and not accessible to the user; they will most likely be