Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r78960:f90be60bb5e3
Date: 2015-08-13 14:32 +0100
http://bitbucket.org/pypy/pypy/changeset/f90be60bb5e3/

Log:    We still need to be a bit more subtle in the non-translated version
        of this function

diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -725,10 +725,16 @@
     result_w = []
     #
     if not we_are_translated():   # fast path before translation
-        for gcref in roots:       # 'roots' is all objects in this case
-            w_obj = callback(gcref)
-            if w_obj is not None:
-                result_w.append(w_obj)
+        seen = set()
+        while roots:
+            gcref = roots.pop()
+            key = (type(gcref), gcref)
+            if key not in seen:
+                seen.add(key)
+                w_obj = callback(gcref)
+                if w_obj is not None:
+                    result_w.append(w_obj)
+                roots.extend(get_rpy_referents(gcref))
         return result_w
     #
     pending = roots[:]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to