Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1767e02

Browse files
committed
free AST's dict
1 parent 4775def commit 1767e02

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Parser/asdl_c.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,12 @@ def visitModule(self, mod):
608608
PyObject *dict;
609609
} AST_object;
610610
611+
static void
612+
ast_dealloc(AST_object *self)
613+
{
614+
Py_CLEAR(self->dict);
615+
}
616+
611617
static int
612618
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
613619
{
@@ -696,7 +702,7 @@ def visitModule(self, mod):
696702
"_ast.AST",
697703
sizeof(AST_object),
698704
0,
699-
0, /* tp_dealloc */
705+
(destructor)ast_dealloc, /* tp_dealloc */
700706
0, /* tp_print */
701707
0, /* tp_getattr */
702708
0, /* tp_setattr */

Python/Python-ast.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ typedef struct {
460460
PyObject *dict;
461461
} AST_object;
462462

463+
static void
464+
ast_dealloc(AST_object *self)
465+
{
466+
Py_CLEAR(self->dict);
467+
}
468+
463469
static int
464470
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
465471
{
@@ -548,7 +554,7 @@ static PyTypeObject AST_type = {
548554
"_ast.AST",
549555
sizeof(AST_object),
550556
0,
551-
0, /* tp_dealloc */
557+
(destructor)ast_dealloc, /* tp_dealloc */
552558
0, /* tp_print */
553559
0, /* tp_getattr */
554560
0, /* tp_setattr */

0 commit comments

Comments
 (0)