[pypy-svn] r79046 - pypy/branch/mapdict-without-jit/pypy/module/gc/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Nov 12 17:48:08 CET 2010
Author: cfbolz
Date: Fri Nov 12 17:48:06 2010
New Revision: 79046
Modified:
pypy/branch/mapdict-without-jit/pypy/module/gc/test/test_gc.py
Log:
Fix a test when using mapdict with local caches. Add a more precise one about
the index cache.
Modified: pypy/branch/mapdict-without-jit/pypy/module/gc/test/test_gc.py
==============================================================================
--- pypy/branch/mapdict-without-jit/pypy/module/gc/test/test_gc.py (original)
+++ pypy/branch/mapdict-without-jit/pypy/module/gc/test/test_gc.py Fri Nov 12 17:48:06 2010
@@ -117,9 +117,12 @@
pass
C().f() # Fill the method cache
rlist.append(weakref.ref(C))
- for i in range(5):
+ for i in range(10):
f()
gc.collect() # the classes C should all go away here
+ # the last class won't go in mapdict, as long as the code object of f
+ # is around
+ rlist.pop()
for r in rlist:
assert r() is None
@@ -127,3 +130,22 @@
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withmethodcache": True,
"objspace.std.withmapdict": True})
+
+
+ def test_clear_index_cache(self):
+ import gc, weakref
+ rlist = []
+ def f():
+ class C(object):
+ def f(self):
+ pass
+ c = C()
+ c.x = 1
+ getattr(c, "x") # fill the index cache without using the local cache
+ getattr(c, "x")
+ rlist.append(weakref.ref(C))
+ for i in range(5):
+ f()
+ gc.collect() # the classes C should all go away here
+ for r in rlist:
+ assert r() is None
More information about the Pypy-commit
mailing list