mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
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.
This commit is contained in:
parent
ef17c16b36
commit
52cc1d838f
25 changed files with 604 additions and 237 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue