[Python-checkins] cpython: free AST's dict

benjamin.peterson python-checkins at python.org
Thu Mar 15 03:50:40 CET 2012


http://hg.python.org/cpython/rev/9e7f6ddc0d76
changeset:   75686:9e7f6ddc0d76
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Mar 14 21:50:29 2012 -0500
summary:
  free AST's dict

files:
  Parser/asdl_c.py    |  8 +++++++-
  Python/Python-ast.c |  8 +++++++-
  2 files changed, 14 insertions(+), 2 deletions(-)


diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -608,6 +608,12 @@
     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 @@
     "_ast.AST",
     sizeof(AST_object),
     0,
-    0,                       /* tp_dealloc */
+    (destructor)ast_dealloc, /* tp_dealloc */
     0,                       /* tp_print */
     0,                       /* tp_getattr */
     0,                       /* tp_setattr */
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -460,6 +460,12 @@
     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 @@
     "_ast.AST",
     sizeof(AST_object),
     0,
-    0,                       /* tp_dealloc */
+    (destructor)ast_dealloc, /* tp_dealloc */
     0,                       /* tp_print */
     0,                       /* tp_getattr */
     0,                       /* tp_setattr */

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list