mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
update Python-ast.c
This commit is contained in:
parent
37d2fe00e1
commit
ce825f1194
1 changed files with 18 additions and 0 deletions
|
@ -621,11 +621,29 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int add_ast_fields()
|
||||||
|
{
|
||||||
|
PyObject *empty_tuple, *d;
|
||||||
|
if (PyType_Ready(&AST_type) < 0)
|
||||||
|
return -1;
|
||||||
|
d = AST_type.tp_dict;
|
||||||
|
empty_tuple = PyTuple_New(0);
|
||||||
|
if (!empty_tuple ||
|
||||||
|
PyDict_SetItemString(d, "_fields", empty_tuple) < 0 ||
|
||||||
|
PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) {
|
||||||
|
Py_XDECREF(empty_tuple);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Py_DECREF(empty_tuple);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int init_types(void)
|
static int init_types(void)
|
||||||
{
|
{
|
||||||
static int initialized;
|
static int initialized;
|
||||||
if (initialized) return 1;
|
if (initialized) return 1;
|
||||||
|
if (add_ast_fields() < 0) return 0;
|
||||||
mod_type = make_type("mod", &AST_type, NULL, 0);
|
mod_type = make_type("mod", &AST_type, NULL, 0);
|
||||||
if (!mod_type) return 0;
|
if (!mod_type) return 0;
|
||||||
if (!add_attributes(mod_type, NULL, 0)) return 0;
|
if (!add_attributes(mod_type, NULL, 0)) return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue