Commit a0ecad50 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix weakref issue for classes inheriting from a pxd

parent 911ca8a1
...@@ -686,13 +686,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -686,13 +686,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"static void %s(PyObject *o) {" "static void %s(PyObject *o) {"
% scope.mangle_internal("tp_dealloc")) % scope.mangle_internal("tp_dealloc"))
py_attrs = [] py_attrs = []
weakref_slot = scope.lookup_here("__weakref__")
for entry in scope.var_entries: 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) 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_self_cast(scope, code)
self.generate_usr_dealloc_call(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);") code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);")
for entry in py_attrs: for entry in py_attrs:
code.put_xdecref("p->%s" % entry.cname, entry.type) code.put_xdecref("p->%s" % entry.cname, entry.type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment