From a0ecad50c2011f212db761655ac895675bc9fbe3 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 26 Apr 2008 11:19:15 -0700 Subject: [PATCH] Fix weakref issue for classes inheriting from a pxd --- Cython/Compiler/ModuleNode.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.26.2