summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-24 23:11:02 +0000
committerBenjamin Peterson <benjamin@python.org>2008-10-24 23:11:02 +0000
commitce825f1194cce637ca3553ab19f19cfbde68e5f9 (patch)
treeb0e2a95fd9cd0b178ef6b0fc4399bf6e3e779732 /Python
parent37d2fe00e1de4f2baf392d6555debcb372836763 (diff)
downloadcpython-git-ce825f1194cce637ca3553ab19f19cfbde68e5f9.tar.gz
update Python-ast.c
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index bf7e4ac1f7..725256350c 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -621,11 +621,29 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
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 initialized;
if (initialized) return 1;
+ if (add_ast_fields() < 0) return 0;
mod_type = make_type("mod", &AST_type, NULL, 0);
if (!mod_type) return 0;
if (!add_attributes(mod_type, NULL, 0)) return 0;