Anonymous
public text v1 · immutable~ $ cat test.py
from snakeoil.weakrefs import WeakRefFinalizer
import gc
class foo(object):
__metaclass__ = WeakRefFinalizer
def __init__(self, attr):
self.attr = attr
def __del__(self):
print("finalization invoked:", self.attr)
def test():
f = foo("foo")
b = foo("bar")
f.b = b
b.f = f
test()
gc.collect()
print("here")
~ $ python2.7 test.py
here
~ $ python3.1 test.py
here