From 56b6a6d9e3bbcded3a0c76f851b8d7cb767e03d4 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 9 Aug 2013 10:09:24 +0200 Subject: [PATCH] be a tiny bit smarter about when to GC_Track for the base type in tp_dealloc() --- Cython/Compiler/ModuleNode.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 5806b1a..a5cc35f 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1243,8 +1243,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if needs_gc: # The base class deallocator probably expects this to be tracked, # so undo the untracking above. - code.putln("if (PyType_IS_GC(Py_TYPE(o)->tp_base))" - " PyObject_GC_Track(o);") + if base_type.scope and base_type.scope.needs_gc(): + code.putln("PyObject_GC_Track(o);") + else: + code.putln("if (PyType_IS_GC(Py_TYPE(o)->tp_base))" + " PyObject_GC_Track(o);") tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot) if tp_dealloc is not None: -- 2.7.4