Author: Gregor Wegberg <[email protected]>
Branch: gc-incminimark-pinning
Changeset: r73269:de940c201b84
Date: 2014-09-01 15:14 +0200
http://bitbucket.org/pypy/pypy/changeset/de940c201b84/
Log: add first simple test for a weakref pointing to a pinned object.
Fails right now.
diff --git a/rpython/memory/test/test_incminimark_gc.py
b/rpython/memory/test/test_incminimark_gc.py
--- a/rpython/memory/test/test_incminimark_gc.py
+++ b/rpython/memory/test/test_incminimark_gc.py
@@ -36,3 +36,27 @@
return ref() is b
res = self.interpret(f, [])
assert res == True
+
+ def test_weakref_to_pinned(self):
+ import weakref
+ from rpython.rlib import rgc
+ class A(object):
+ pass
+ def g():
+ a = A()
+ assert rgc.pin(a)
+ a.x = 100
+ wr = weakref.ref(a)
+ llop.gc__collect(lltype.Void)
+ assert wr() is not None
+ assert a.x == 100
+ return wr
+ def f():
+ ref = g()
+ llop.gc__collect(lltype.Void, 1)
+ b = ref()
+ assert b is not None
+ b.x = 101
+ return ref() is b
+ res = self.interpret(f, [])
+ assert res == True
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit