be a tiny bit smarter about when to GC_Track for the base type in tp_dealloc()
authorStefan Behnel <stefan_ml@behnel.de>
Fri, 9 Aug 2013 08:09:24 +0000 (10:09 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Fri, 9 Aug 2013 08:09:24 +0000 (10:09 +0200)
Cython/Compiler/ModuleNode.py

index 5806b1a..a5cc35f 100644 (file)
@@ -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: