Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r75886:cce58dd9c317
Date: 2015-02-15 10:13 +0100
http://bitbucket.org/pypy/pypy/changeset/cce58dd9c317/

Log:    issue #1984 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
@@ -49,9 +49,6 @@
 
     def switch(self, w_to):
         sthread = self.sthread
-        if sthread is not None and sthread.is_empty_handle(self.h):
-            global_state.clear()
-            raise geterror(self.space, "continulet already finished")
         to = self.space.interp_w(W_Continulet, w_to, can_be_None=True)
         if to is not None and to.sthread is None:
             to = None
@@ -62,6 +59,9 @@
                 to = None
             else:
                 return get_result()  # else: no-op
+        if sthread is not None and sthread.is_empty_handle(self.h):
+            global_state.clear()
+            raise geterror(self.space, "continulet already finished")
         if to is not None:
             if to.sthread is not sthread:
                 global_state.clear()
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
@@ -698,3 +698,12 @@
         except ZeroDivisionError:
             got = c1.switch()
         assert got == (None, None, None)
+
+    def test_bug_issue1984(self):
+        from _continuation import continulet, error
+
+        c1 = continulet.__new__(continulet)
+        c2 = continulet(lambda g: None)
+
+        continulet.switch(c1, to=c2)
+        raises(error, continulet.switch, c1, to=c2)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to