Commit fb2515af authored by Rudi Chen's avatar Rudi Chen

Use weakref's original tp_dealloc.

parent 22b388e9
......@@ -544,7 +544,9 @@ proxy_dealloc(PyWeakReference *self)
if (self->wr_callback != NULL)
PyObject_GC_UnTrack((PyObject *)self);
clear_weakref(self);
PyObject_GC_Del(self);
// Pyston change: we monkey-patch this function to use the Pyston GC
// Shouldn't need to call tp_free either.
// PyObject_GC_Del(self);
}
/* sequence slots */
......
......@@ -1152,11 +1152,6 @@ static void proxy_to_tp_traverse(GCVisitor* v, Box* b) {
b->cls->tp_traverse(b, call_gc_visit, v);
}
static void proxy_to_tp_clear(Box* b) {
assert(b->cls->tp_clear);
b->cls->tp_clear(b);
}
// This probably belongs in tuple.cpp?
extern "C" void tupleGCHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b);
......@@ -2932,15 +2927,11 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
}
// Normally we don't call the Python tp_ slots that are present to support
// CPython's reference-counted garbage collection. However, for a few types
// like weak references, we still rely on reference-counting to some extent.
// CPython's reference-counted garbage collection.
static void setTypeGCProxy(BoxedClass* cls) {
cls->tp_alloc = PystonType_GenericAlloc;
cls->tp_free = default_free;
cls->gc_visit = proxy_to_tp_traverse;
// We can't use the original tp_dealloc here, the dealloc method of some
// types like ProxyType explicitely frees itself without using tp_free.
cls->tp_dealloc = proxy_to_tp_clear;
cls->has_safe_tp_dealloc = true;
cls->is_pyston_class = true;
}
......
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