Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r54993:e37769dd2e8e Date: 2012-05-09 20:13 +0200 http://bitbucket.org/pypy/pypy/changeset/e37769dd2e8e/
Log: A failing test about weak key dictionaries. diff --git a/pypy/rlib/test/test_rweakkeydict.py b/pypy/rlib/test/test_rweakkeydict.py --- a/pypy/rlib/test/test_rweakkeydict.py +++ b/pypy/rlib/test/test_rweakkeydict.py @@ -135,3 +135,31 @@ d = RWeakKeyDictionary(KX, VY) d.set(KX(), VX()) py.test.raises(Exception, interpret, g, [1]) + + +def test_rpython_free_values(): + class VXDel: + def __del__(self): + state.freed.append(1) + class State: + pass + state = State() + state.freed = [] + # + def add_me(): + k = KX() + v = VXDel() + d = RWeakKeyDictionary(KX, VXDel) + d.set(k, v) + return d + def f(): + del state.freed[:] + d = add_me() + rgc.collect() + # we want the dictionary to be really empty here. It's hard to + # ensure in the current implementation after just one collect(), + # but at least two collects should be enough. + rgc.collect() + return len(state.freed) + assert f() == 1 + assert interpret(f, []) == 1 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit