Commit 89e58ec0 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Inherit tp_traverse and tp_clear from the base class

We used to just ignore these, but we can call these from
the proxy_to_tp_traverse and proxy_to_tp_clear adapters.
parent 2d5ea781
...@@ -364,6 +364,13 @@ BoxedClass::BoxedClass(BoxedClass* base, gcvisit_func gc_visit, int attrs_offset ...@@ -364,6 +364,13 @@ BoxedClass::BoxedClass(BoxedClass* base, gcvisit_func gc_visit, int attrs_offset
} }
void BoxedClass::finishInitialization() { void BoxedClass::finishInitialization() {
assert(!tp_traverse);
assert(!tp_clear);
if (tp_base) {
tp_traverse = tp_base->tp_traverse;
tp_clear = tp_base->tp_clear;
}
commonClassSetup(this); commonClassSetup(this);
} }
...@@ -2825,7 +2832,7 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg ...@@ -2825,7 +2832,7 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
else else
r = chosen_cf->call(oarg1, oarg2, oarg3, oargs); r = chosen_cf->call(oarg1, oarg2, oarg3, oargs);
ASSERT(chosen_cf->spec->rtn_type->isFitBy(r->cls), "%s (%p) %s %s", ASSERT(chosen_cf->spec->rtn_type->isFitBy(r->cls), "%s (%p) was supposed to return %s, but gave a %s",
g.func_addr_registry.getFuncNameAtAddress(chosen_cf->code, true, NULL).c_str(), chosen_cf->code, g.func_addr_registry.getFuncNameAtAddress(chosen_cf->code, true, NULL).c_str(), chosen_cf->code,
chosen_cf->spec->rtn_type->debugName().c_str(), r->cls->tp_name); chosen_cf->spec->rtn_type->debugName().c_str(), r->cls->tp_name);
return r; return r;
......
...@@ -511,10 +511,13 @@ static int call_gc_visit(PyObject* val, void* arg) { ...@@ -511,10 +511,13 @@ static int call_gc_visit(PyObject* val, void* arg) {
static void proxy_to_tp_traverse(GCVisitor* v, Box* b) { static void proxy_to_tp_traverse(GCVisitor* v, Box* b) {
boxGCHandler(v, b); boxGCHandler(v, b);
assert(b->cls->tp_traverse);
b->cls->tp_traverse(b, call_gc_visit, v); b->cls->tp_traverse(b, call_gc_visit, v);
} }
static void proxy_to_tp_clear(Box* b) { static void proxy_to_tp_clear(Box* b) {
assert(b->cls->tp_clear);
b->cls->tp_clear(b); b->cls->tp_clear(b);
} }
......
# Make sure we can subclass from weakref.ref, since the weakref module itself does this
from weakref import ref
class MyRef(ref):
pass
for i in xrange(100):
m = MyRef(MyRef)
import gc
gc.collect()
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