fix subclassing non-GC types like 'unicode'
authorStefan Behnel <scoder@users.berlios.de>
Wed, 9 Jan 2008 22:15:09 +0000 (23:15 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 9 Jan 2008 22:15:09 +0000 (23:15 +0100)
Cython/Compiler/ModuleNode.py

index 05befd1bba2df0066760019fbcf28e49b9b523e8..898a393a4f70582ea1d9b8b72dbdfb0d5ca6c18d 100644 (file)
@@ -723,9 +723,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         if py_attrs:
             self.generate_self_cast(scope, code)
         if base_type:
+            code.putln("if (PyType_IS_GC(%s)) {" % base_type.typeptr_cname)
             code.putln(
                     "e = %s->tp_traverse(o, v, a); if (e) return e;" %
                         base_type.typeptr_cname)
+            code.putln("}")
         for entry in py_attrs:
             var_code = "p->%s" % entry.cname
             code.putln(
@@ -756,9 +758,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         if py_attrs:
             self.generate_self_cast(scope, code)
         if base_type:
+            code.putln("if (PyType_IS_GC(%s)) {" % base_type.typeptr_cname)
             code.putln(
                 "%s->tp_clear(o);" %
                     base_type.typeptr_cname)
+            code.putln("}")
         for entry in py_attrs:
             name = "p->%s" % entry.cname
             code.put_xdecref(name, entry.type)