Commit 31a03a8d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Involve instance attributes in GC

I copied subtype_traverse and subtype_clear from cpython but
didn't update them to support our hcattrs
parent c9cd0170
......@@ -827,6 +827,10 @@ static int subtype_traverse(PyObject* self, visitproc visit, void* arg) noexcept
Py_VISIT(*dictptr);
}
if (type->attrs_offset != base->attrs_offset) {
Py_TRAVERSE(*self->getHCAttrsPtr());
}
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE)
/* For a heaptype, the instances count as references
to the type. Traverse the type so the collector
......@@ -861,6 +865,10 @@ static int subtype_clear(PyObject* self) noexcept {
Py_CLEAR(*dictptr);
}
if (type->attrs_offset != base->attrs_offset) {
self->getHCAttrsPtr()->clear();
}
if (baseclear)
return baseclear(self);
return 0;
......
class C(object):
pass
c = C()
c.t = (c,)
# expected: reffail
class C(object):
def __init__(self):
self.t = set([self])
......
# expected: reffail
# Some parsing tests:
print ((1, 2),)
print (1, 2, 3)
......
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