From da5b701aeef755f2317a41e36cc950cfdc0c95cb Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 2 May 2006 19:47:52 +0000 Subject: Get rid of __context__, per the latest changes to PEP 343 and python-dev discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself. --- Python/compile.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'Python') diff --git a/Python/compile.c b/Python/compile.c index 8b6f2f1c08..15e7e15811 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3371,7 +3371,7 @@ expr_constant(expr_ty e) It is implemented roughly as: - context = (EXPR).__context__() + context = EXPR exit = context.__exit__ # not calling it value = context.__enter__() try: @@ -3387,17 +3387,12 @@ expr_constant(expr_ty e) static int compiler_with(struct compiler *c, stmt_ty s) { - static identifier context_attr, enter_attr, exit_attr; + static identifier enter_attr, exit_attr; basicblock *block, *finally; identifier tmpexit, tmpvalue = NULL; assert(s->kind == With_kind); - if (!context_attr) { - context_attr = PyString_InternFromString("__context__"); - if (!context_attr) - return 0; - } if (!enter_attr) { enter_attr = PyString_InternFromString("__enter__"); if (!enter_attr) @@ -3436,10 +3431,8 @@ compiler_with(struct compiler *c, stmt_ty s) PyArena_AddPyObject(c->c_arena, tmpvalue); } - /* Evaluate (EXPR).__context__() */ + /* Evaluate EXPR */ VISIT(c, expr, s->v.With.context_expr); - ADDOP_O(c, LOAD_ATTR, context_attr, names); - ADDOP_I(c, CALL_FUNCTION, 0); /* Squirrel away context.__exit__ */ ADDOP(c, DUP_TOP); -- cgit v1.2.1