From: Robert Bradshaw Date: Sat, 26 Apr 2008 18:19:15 +0000 (-0700) Subject: Fix weakref issue for classes inheriting from a pxd X-Git-Tag: 0.9.6.14~21^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a0ecad50c2011f212db761655ac895675bc9fbe3;p=cython.git Fix weakref issue for classes inheriting from a pxd --- diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 4a58885a..9eed6d2c 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -686,13 +686,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): "static void %s(PyObject *o) {" % scope.mangle_internal("tp_dealloc")) py_attrs = [] + weakref_slot = scope.lookup_here("__weakref__") for entry in scope.var_entries: - if entry.type.is_pyobject and entry.name != "__weakref__": + if entry.type.is_pyobject and entry is not weakref_slot: py_attrs.append(entry) - if py_attrs or scope.lookup_here("__weakref__"): + print py_attrs + if py_attrs or weakref_slot in scope.var_entries: self.generate_self_cast(scope, code) self.generate_usr_dealloc_call(scope, code) - if scope.lookup_here("__weakref__"): + if weakref_slot in scope.var_entries: code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);") for entry in py_attrs: code.put_xdecref("p->%s" % entry.cname, entry.type)