Author: Armin Rigo <[email protected]>
Branch:
Changeset: r58781:94bb334acb64
Date: 2012-11-07 12:57 +0100
http://bitbucket.org/pypy/pypy/changeset/94bb334acb64/
Log: Test and fix.
diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py
--- a/pypy/module/gc/referents.py
+++ b/pypy/module/gc/referents.py
@@ -107,8 +107,9 @@
w_obj = head.get_most_recent_w_obj()
if w_obj is not None:
result_w[w_obj] = None # found!
- rgc.toggle_gcflag_extra(gcref)
- head = PathEntry(head, gcref, rgc.get_rpy_referents(gcref))
+ else:
+ rgc.toggle_gcflag_extra(gcref)
+ head = PathEntry(head, gcref, rgc.get_rpy_referents(gcref))
else:
# no more referents to visit
head = head.prev
diff --git a/pypy/module/gc/test/test_referents.py
b/pypy/module/gc/test/test_referents.py
--- a/pypy/module/gc/test/test_referents.py
+++ b/pypy/module/gc/test/test_referents.py
@@ -13,7 +13,8 @@
l4 = space.newlist([w(4)])
l2 = space.newlist([w(2)])
l7 = space.newlist([w(7)])
- cls.ALL_ROOTS = [l4, space.newlist([l2, l7]), RandomRPythonObject()]
+ cls.ALL_ROOTS = [l4, space.newlist([l2, l7]), RandomRPythonObject(),
+ space.newtuple([l7])]
cls.w_ALL_ROOTS = cls.space.newlist(cls.ALL_ROOTS)
rgc.get_rpy_roots = lambda: (
map(rgc._GcRef, cls.ALL_ROOTS) + [rgc.NULL_GCREF]*17)
@@ -26,7 +27,7 @@
def test_get_objects(self):
import gc
lst = gc.get_objects()
- i4, l27, ro = self.ALL_ROOTS
+ i4, l27, ro, rt = self.ALL_ROOTS
i2, i7 = l27
found = 0
for x in lst:
@@ -48,7 +49,8 @@
assert lst[0] == [4]
assert lst[1] == [[2], [7]]
assert type(lst[2]) is gc.GcRef
- assert len(lst) == 3
+ assert lst[3] == ([7],)
+ assert len(lst) == 4
def test_get_rpy_referents(self):
import gc
@@ -108,3 +110,9 @@
break # found
else:
assert 0, "the list [2, 7] is not found as gc.get_referrers(7)"
+ l7t = self.ALL_ROOTS[3]
+ for x in lst:
+ if x is l7t:
+ break # found
+ else:
+ assert 0, "the tuple (7,) is not found as gc.get_referrers(7)"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit