From: Stefan Behnel Date: Wed, 9 Jan 2008 22:28:26 +0000 (+0100) Subject: fix subclassing non-GC types like 'unicode' X-Git-Tag: 0.9.6.14~29^2~62^2~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3b8a1a8c77ab5445509442b0ae01733f7b171bc5;p=cython.git fix subclassing non-GC types like 'unicode' --- diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 05befd1b..758546da 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -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 (%s->tp_traverse) {" % 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 (%s->tp_clear) {" % 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)