]> granicus.if.org Git - python/commitdiff
free AST's dict
authorBenjamin Peterson <benjamin@python.org>
Thu, 15 Mar 2012 02:50:29 +0000 (21:50 -0500)
committerBenjamin Peterson <benjamin@python.org>
Thu, 15 Mar 2012 02:50:29 +0000 (21:50 -0500)
Parser/asdl_c.py
Python/Python-ast.c

index 0be6c7fe81682c42596dc60a8ca086d26d96662e..81a3d6af588a51b926a21d5a0953a012faa9a2d3 100755 (executable)
@@ -608,6 +608,12 @@ typedef struct {
     PyObject *dict;
 } AST_object;
 
+static void
+ast_dealloc(AST_object *self)
+{
+    Py_CLEAR(self->dict);
+}
+
 static int
 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
 {
@@ -696,7 +702,7 @@ static PyTypeObject AST_type = {
     "_ast.AST",
     sizeof(AST_object),
     0,
-    0,                       /* tp_dealloc */
+    (destructor)ast_dealloc, /* tp_dealloc */
     0,                       /* tp_print */
     0,                       /* tp_getattr */
     0,                       /* tp_setattr */
index 1178d74d7f9dc280181e36a6641a6ccac632b42a..d9e13e28b0d97162729bd9d4b6ec0469491ca1c2 100644 (file)
@@ -460,6 +460,12 @@ typedef struct {
     PyObject *dict;
 } AST_object;
 
+static void
+ast_dealloc(AST_object *self)
+{
+    Py_CLEAR(self->dict);
+}
+
 static int
 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
 {
@@ -548,7 +554,7 @@ static PyTypeObject AST_type = {
     "_ast.AST",
     sizeof(AST_object),
     0,
-    0,                       /* tp_dealloc */
+    (destructor)ast_dealloc, /* tp_dealloc */
     0,                       /* tp_print */
     0,                       /* tp_getattr */
     0,                       /* tp_setattr */