summaryrefslogtreecommitdiff
path: root/Parser
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-07-08 11:03:46 -0700
committerBenjamin Peterson <benjamin@python.org>2012-07-08 11:03:46 -0700
commit8107176f9b540dbcec16d0a551f5cee4e26e4f74 (patch)
tree5b65351499fe9833367e7f4916796137070e8458 /Parser
parent4d378d834971179acf14c3ba019f64eafa9b6473 (diff)
downloadcpython-git-8107176f9b540dbcec16d0a551f5cee4e26e4f74.tar.gz
add gc support to the AST base type (closes #15293)
Diffstat (limited to 'Parser')
-rwxr-xr-xParser/asdl_c.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index e4165b09ad..698afacf89 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -616,6 +616,19 @@ ast_dealloc(AST_object *self)
}
static int
+ast_traverse(AST_object *self, visitproc visit, void *arg)
+{
+ Py_VISIT(self->dict);
+ return 0;
+}
+
+static void
+ast_clear(AST_object *self)
+{
+ Py_CLEAR(self->dict);
+}
+
+static int
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
{
_Py_IDENTIFIER(_fields);
@@ -718,10 +731,10 @@ static PyTypeObject AST_type = {
PyObject_GenericGetAttr, /* tp_getattro */
PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
+ (traverseproc)ast_traverse, /* tp_traverse */
+ (inquiry)ast_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
@@ -737,7 +750,7 @@ static PyTypeObject AST_type = {
(initproc)ast_type_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
- PyObject_Del, /* tp_free */
+ PyObject_GC_Del, /* tp_free */
};