diff Python/compile.c @ 38084:a812d0fae74a legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Tue, 02 May 2006 19:47:52 +0000
parents 5e72b0c74100
children 8f7c7aeac3a5
line wrap: on
line diff
--- a/Python/compile.c	Tue May 02 17:36:09 2006 +0000
+++ b/Python/compile.c	Tue May 02 19:47:52 2006 +0000
@@ -3371,7 +3371,7 @@
   
    It is implemented roughly as:
   
-   context = (EXPR).__context__()
+   context = EXPR
    exit = context.__exit__  # not calling it
    value = context.__enter__()
    try:
@@ -3387,17 +3387,12 @@
 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 @@
 	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);