diff options
-rwxr-xr-x | Parser/asdl_c.py | 6 | ||||
-rw-r--r-- | Python/Python-ast.c | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 6b31ffd8..0b72f9e 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -638,9 +638,13 @@ static void ast_dealloc(AST_object *self) { /* bpo-31095: UnTrack is needed before calling any callbacks */ + PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); Py_CLEAR(self->dict); - Py_TYPE(self)->tp_free(self); + freefunc free_func = PyType_GetSlot(tp, Py_tp_free); + assert(free_func != NULL); + free_func(self); + Py_DECREF(tp); } static int diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 5190a90..7a38e98 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1130,9 +1130,13 @@ static void ast_dealloc(AST_object *self) { /* bpo-31095: UnTrack is needed before calling any callbacks */ + PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); Py_CLEAR(self->dict); - Py_TYPE(self)->tp_free(self); + freefunc free_func = PyType_GetSlot(tp, Py_tp_free); + assert(free_func != NULL); + free_func(self); + Py_DECREF(tp); } static int |