[pypy-commit] pypy stacklet: Test and fix.

arigo noreply at buildbot.pypy.org
Thu Aug 18 09:38:11 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stacklet
Changeset: r46588:fd3cc2185ccf
Date: 2011-08-17 22:08 +0200
http://bitbucket.org/pypy/pypy/changeset/fd3cc2185ccf/

Log:	Test and fix.

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
@@ -146,6 +146,9 @@
     try:
         ec = self.sthread.ec
         ec.topframeref = jit.vref_None
+        if start_state.w_value is not space.w_None:
+            raise OperationError(space.w_TypeError, space.wrap(
+                "can't send non-None value to a just-started continuation"))
         args = args.prepend(space.wrap(self))
         w_result = space.call_args(w_callable, args)
     except Exception, e:
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
@@ -102,6 +102,19 @@
         assert res == 'c'
         assert seen == [0, 1, 2, 3]
 
+    def test_initial_switch_must_give_None(self):
+        from _continuation import continuation
+        #
+        def empty_callback(c):
+            return 'ok'
+        #
+        c = continuation(empty_callback)
+        res = c.switch(None)
+        assert res == 'ok'
+        #
+        c = continuation(empty_callback)
+        raises(TypeError, c.switch, 'foo')
+
     def test_continuation_error(self):
         from _continuation import continuation, error
         #


More information about the pypy-commit mailing list