comparison Python/Python-ast.c @ 49583:2a38771cecdd

update Python-ast.c
author Benjamin Peterson <benjamin@python.org>
date Fri, 24 Oct 2008 23:11:02 +0000
parents 6ae2d4b507a2
children f66688e69f66
comparison
equal deleted inserted replaced
49582:8420af6c33ed 49583:2a38771cecdd
619 return 1; 619 return 1;
620 *out = i; 620 *out = i;
621 return 0; 621 return 0;
622 } 622 }
623 623
624 static int add_ast_fields()
625 {
626 PyObject *empty_tuple, *d;
627 if (PyType_Ready(&AST_type) < 0)
628 return -1;
629 d = AST_type.tp_dict;
630 empty_tuple = PyTuple_New(0);
631 if (!empty_tuple ||
632 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 ||
633 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) {
634 Py_XDECREF(empty_tuple);
635 return -1;
636 }
637 Py_DECREF(empty_tuple);
638 return 0;
639 }
640
624 641
625 static int init_types(void) 642 static int init_types(void)
626 { 643 {
627 static int initialized; 644 static int initialized;
628 if (initialized) return 1; 645 if (initialized) return 1;
646 if (add_ast_fields() < 0) return 0;
629 mod_type = make_type("mod", &AST_type, NULL, 0); 647 mod_type = make_type("mod", &AST_type, NULL, 0);
630 if (!mod_type) return 0; 648 if (!mod_type) return 0;
631 if (!add_attributes(mod_type, NULL, 0)) return 0; 649 if (!add_attributes(mod_type, NULL, 0)) return 0;
632 Module_type = make_type("Module", mod_type, Module_fields, 1); 650 Module_type = make_type("Module", mod_type, Module_fields, 1);
633 if (!Module_type) return 0; 651 if (!Module_type) return 0;