Author: Antonio Cuni <[email protected]>
Branch: continulet-no-frame-loop-2
Changeset: r93061:8c14e037eea6
Date: 2017-11-16 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/8c14e037eea6/

Log:    fix permute, and rewrite the corresponding test since we can no
        longer check what is the 'back' frame

diff --git a/pypy/module/_continuation/interp_continuation.py 
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -280,8 +280,7 @@
     #
     if len(contlist) > 1:
         otherh = contlist[-1].h
-        otherb = contlist[-1].bottomframe.f_backref
+        otherb = contlist[-1].backframeref
         for cont in contlist:
             otherh, cont.h = cont.h, otherh
-            b = cont.bottomframe
-            otherb, b.f_backref = b.f_backref, otherb
+            otherb, cont.backframeref = cont.backframeref, otherb
diff --git a/pypy/module/_continuation/test/test_stacklet.py 
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -714,24 +714,31 @@
         import sys
         from _continuation import continulet, permute
         #
-        def f1(c1):
-            res = c1.switch()
-            assert res == "ok"
-            return "done"
+        def a(c):
+            seen.append(2)
+            res = c.switch()
+            assert res == 'b'
+            seen.append(6)
+            return 'a'
+        def b(c):
+            seen.append(3)
+            c.switch()
+            seen.append(5)
+            return 'b'
         #
-        def f2(c2):
-            assert sys._getframe(1).f_code.co_name == 'main'
-            permute(c1, c2)
-            assert sys._getframe(1).f_code.co_name == 'f1'
-            return "ok"
-        #
-        c1 = continulet(f1)
-        c2 = continulet(f2)
-        def main():
-            c1.switch()
-            res = c2.switch()
-            assert res == "done"
-        main()
+        seen = []
+        c1 = continulet(a)
+        c2 = continulet(b)
+        seen.append(1)
+        c1.switch()
+        c2.switch()
+        seen.append(4)
+        permute(c1, c2)
+        res = c1.switch()
+        assert res == 'a'
+        assert not c2.is_pending()
+        seen.append(7)
+        assert seen == [1, 2, 3, 4, 5, 6, 7]
 
     def test_permute_noninitialized(self):
         from _continuation import continulet, permute
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to