Fix weakref issue for classes inheriting from a pxd
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 26 Apr 2008 18:19:15 +0000 (11:19 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 26 Apr 2008 18:19:15 +0000 (11:19 -0700)
Cython/Compiler/ModuleNode.py

index 4a58885a527fba9e99e28ce4703b727bdd55c6b6..9eed6d2cf83f209ee4b973f67bf3e15e07519d40 100644 (file)
@@ -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)