[pypy-svn] r26976 - in pypy/dist/pypy/translator/stackless: . test

arigo at codespeak.net arigo at codespeak.net
Mon May 8 19:34:45 CEST 2006


Author: arigo
Date: Mon May  8 19:34:44 2006
New Revision: 26976

Modified:
   pypy/dist/pypy/translator/stackless/code.py
   pypy/dist/pypy/translator/stackless/test/test_yield_current_frame_to_caller.py
Log:
(pedronis, arigo)
Oups, bug fix.  See comment in code.


Modified: pypy/dist/pypy/translator/stackless/code.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/code.py	(original)
+++ pypy/dist/pypy/translator/stackless/code.py	Mon May  8 19:34:44 2006
@@ -123,7 +123,7 @@
                                                          our_caller_state)
         raise UnwindException()  # this goes to the caller's caller
 
-    else:
+    elif global_state.restart_substate == 2:
         # STATE 2: this is a slight abuse of yield_current_frame_to_caller(),
         # as we return here when our immediate caller returns (and thus the
         # new tasklet finishes).
@@ -136,6 +136,13 @@
         raise UnwindException()  # this goes to the switch target given by
                                  # the 'return' at the end of our caller
 
+    else:
+        # STATE 3: this is never reached!  But the annotator doesn't know it,
+        # so it makes the whole function be annotated as returning a random
+        # non-constant STATE_HEADER pointer.
+        return lltype.cast_opaque_ptr(OPAQUE_STATE_HEADER_PTR,
+                                      global_state.top)
+
 yield_current_frame_to_caller.stackless_explicit = True
 
 def stack_frames_depth():

Modified: pypy/dist/pypy/translator/stackless/test/test_yield_current_frame_to_caller.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_yield_current_frame_to_caller.py	(original)
+++ pypy/dist/pypy/translator/stackless/test/test_yield_current_frame_to_caller.py	Mon May  8 19:34:44 2006
@@ -17,9 +17,11 @@
     def test_simple(self):
         def f():
             c = g()
+            assert c
             return 1
         def g():
-            self.yield_current_frame_to_caller()
+            d = self.yield_current_frame_to_caller()
+            return d
 
         data = llinterp_stackless_function(f)
         assert data == 1



More information about the Pypy-commit mailing list