diff Python/Python-ast.c @ 39782:c94f37054f19

Patch #1550800: make exec a function.
author Georg Brandl <georg@python.org>
date Wed, 06 Sep 2006 06:51:57 +0000
parents da3a9f402886
children 7a0ad110e91e
line wrap: on
line diff
--- a/Python/Python-ast.c	Thu Aug 31 21:45:56 2006 +0000
+++ b/Python/Python-ast.c	Wed Sep 06 06:51:57 2006 +0000
@@ -123,12 +123,6 @@
         "names",
         "level",
 };
-static PyTypeObject *Exec_type;
-static char *Exec_fields[]={
-        "body",
-        "globals",
-        "locals",
-};
 static PyTypeObject *Global_type;
 static char *Global_fields[]={
         "names",
@@ -494,8 +488,6 @@
         ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields,
                                     3);
         if (!ImportFrom_type) return 0;
-        Exec_type = make_type("Exec", stmt_type, Exec_fields, 3);
-        if (!Exec_type) return 0;
         Global_type = make_type("Global", stmt_type, Global_fields, 1);
         if (!Global_type) return 0;
         Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
@@ -1170,30 +1162,6 @@
 }
 
 stmt_ty
-Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int col_offset,
-     PyArena *arena)
-{
-        stmt_ty p;
-        if (!body) {
-                PyErr_SetString(PyExc_ValueError,
-                                "field body is required for Exec");
-                return NULL;
-        }
-        p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
-        if (!p) {
-                PyErr_NoMemory();
-                return NULL;
-        }
-        p->kind = Exec_kind;
-        p->v.Exec.body = body;
-        p->v.Exec.globals = globals;
-        p->v.Exec.locals = locals;
-        p->lineno = lineno;
-        p->col_offset = col_offset;
-        return p;
-}
-
-stmt_ty
 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
 {
         stmt_ty p;
@@ -2274,25 +2242,6 @@
                         goto failed;
                 Py_DECREF(value);
                 break;
-        case Exec_kind:
-                result = PyType_GenericNew(Exec_type, NULL, NULL);
-                if (!result) goto failed;
-                value = ast2obj_expr(o->v.Exec.body);
-                if (!value) goto failed;
-                if (PyObject_SetAttrString(result, "body", value) == -1)
-                        goto failed;
-                Py_DECREF(value);
-                value = ast2obj_expr(o->v.Exec.globals);
-                if (!value) goto failed;
-                if (PyObject_SetAttrString(result, "globals", value) == -1)
-                        goto failed;
-                Py_DECREF(value);
-                value = ast2obj_expr(o->v.Exec.locals);
-                if (!value) goto failed;
-                if (PyObject_SetAttrString(result, "locals", value) == -1)
-                        goto failed;
-                Py_DECREF(value);
-                break;
         case Global_kind:
                 result = PyType_GenericNew(Global_type, NULL, NULL);
                 if (!result) goto failed;
@@ -3082,7 +3031,6 @@
             return;
         if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) <
             0) return;
-        if (PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return;
         if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0)
             return;
         if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return;