summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-03-18 15:41:51 (GMT)
committerGuido van Rossum <guido@python.org>2007-03-18 15:41:51 (GMT)
commit52cc1d838f4fee573e57b5b182d8e5f5db63240f (patch)
tree0ea50468d2b04ee12131c155c5918e8a70dafe1c /Python/Python-ast.c
parentef17c16b366b09a78dfe5fc5171fe2b0b29f60e5 (diff)
downloadcpython-52cc1d838f4fee573e57b5b182d8e5f5db63240f.zip
cpython-52cc1d838f4fee573e57b5b182d8e5f5db63240f.tar.gz
cpython-52cc1d838f4fee573e57b5b182d8e5f5db63240f.tar.bz2
Implement PEP 3115 -- new metaclass syntax and semantics.
The compiler package hasn't been updated yet; test_compiler.py fails. Otherwise all tests seem to be passing now. There are no occurrences of __metaclass__ left in the standard library. Docs have not been updated.
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index c024a62..76c86c1 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -49,6 +49,9 @@ static PyTypeObject *ClassDef_type;
static char *ClassDef_fields[]={
"name",
"bases",
+ "keywords",
+ "starargs",
+ "kwargs",
"body",
};
static PyTypeObject *Return_type;
@@ -477,7 +480,7 @@ static int init_types(void)
FunctionDef_type = make_type("FunctionDef", stmt_type,
FunctionDef_fields, 5);
if (!FunctionDef_type) return 0;
- ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 3);
+ ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 6);
if (!ClassDef_type) return 0;
Return_type = make_type("Return", stmt_type, Return_fields, 1);
if (!Return_type) return 0;
@@ -835,8 +838,9 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
}
stmt_ty
-ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno, int
- col_offset, PyArena *arena)
+ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty
+ starargs, expr_ty kwargs, asdl_seq * body, int lineno, int col_offset,
+ PyArena *arena)
{
stmt_ty p;
if (!name) {
@@ -850,6 +854,9 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno, int
p->kind = ClassDef_kind;
p->v.ClassDef.name = name;
p->v.ClassDef.bases = bases;
+ p->v.ClassDef.keywords = keywords;
+ p->v.ClassDef.starargs = starargs;
+ p->v.ClassDef.kwargs = kwargs;
p->v.ClassDef.body = body;
p->lineno = lineno;
p->col_offset = col_offset;
@@ -1974,6 +1981,21 @@ ast2obj_stmt(void* _o)
if (PyObject_SetAttrString(result, "bases", value) == -1)
goto failed;
Py_DECREF(value);
+ value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword);
+ if (!value) goto failed;
+ if (PyObject_SetAttrString(result, "keywords", value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_expr(o->v.ClassDef.starargs);
+ if (!value) goto failed;
+ if (PyObject_SetAttrString(result, "starargs", value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_expr(o->v.ClassDef.kwargs);
+ if (!value) goto failed;
+ if (PyObject_SetAttrString(result, "kwargs", value) == -1)
+ goto failed;
+ Py_DECREF(value);
value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttrString(result, "body", value) == -1)