[pypy-svn] r40634 - in pypy/dist/pypy/module: _pickle_support _stackless _stackless/test

arigo at codespeak.net arigo at codespeak.net
Sat Mar 17 14:09:33 CET 2007


Author: arigo
Date: Sat Mar 17 14:09:31 2007
New Revision: 40634

Modified:
   pypy/dist/pypy/module/_pickle_support/__init__.py
   pypy/dist/pypy/module/_pickle_support/maker.py
   pypy/dist/pypy/module/_stackless/__init__.py
   pypy/dist/pypy/module/_stackless/coroutine.py
   pypy/dist/pypy/module/_stackless/test/test_pickle.py
Log:
(pedronis, arigo)

Move return_main() to the _stackless module.  May fix the fact that
translating even a non-stackless PyPy is not possible if you don't
have the py lib's greenlets.


Modified: pypy/dist/pypy/module/_pickle_support/__init__.py
==============================================================================
--- pypy/dist/pypy/module/_pickle_support/__init__.py	(original)
+++ pypy/dist/pypy/module/_pickle_support/__init__.py	Sat Mar 17 14:09:31 2007
@@ -19,5 +19,4 @@
         'frame_new'    : 'maker.frame_new',
         'traceback_new' : 'maker.traceback_new',
         'generator_new' : 'maker.generator_new',
-        'return_main' : 'maker.return_main',
     }

Modified: pypy/dist/pypy/module/_pickle_support/maker.py
==============================================================================
--- pypy/dist/pypy/module/_pickle_support/maker.py	(original)
+++ pypy/dist/pypy/module/_pickle_support/maker.py	Sat Mar 17 14:09:31 2007
@@ -80,11 +80,6 @@
     return space.wrap(new_generator)
 generator_new.unwrap_spec = [ObjSpace, Arguments]
 
-def return_main(space):
-    from pypy.module._stackless.coroutine import AppCoroutine
-    return AppCoroutine._get_state(space).main
-return_main.unwrap_spec = [ObjSpace]
-
 # ___________________________________________________________________
 # Helper functions for internal use
 

Modified: pypy/dist/pypy/module/_stackless/__init__.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/__init__.py	(original)
+++ pypy/dist/pypy/module/_stackless/__init__.py	Sat Mar 17 14:09:31 2007
@@ -16,6 +16,7 @@
         'coroutine'  : 'coroutine.AppCoroutine',
         'greenlet'   : 'interp_greenlet.AppGreenlet',
         'usercostate': 'composable_coroutine.W_UserCoState',
+        '_return_main' : 'coroutine.return_main',
     }
 
     def setup_after_space_initialization(self):

Modified: pypy/dist/pypy/module/_stackless/coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/coroutine.py	(original)
+++ pypy/dist/pypy/module/_stackless/coroutine.py	Sat Mar 17 14:09:31 2007
@@ -148,7 +148,7 @@
         ec = self.space.getexecutioncontext()
 
         if self is self.costate.main:
-            return nt([mod2.get('return_main'), nt([])])
+            return nt([mod.get('_return_main'), nt([])])
 
         thunk = self.thunk
         if isinstance(thunk, _AppThunk):
@@ -317,3 +317,7 @@
     def post_install(self):
         self.current = self.main = AppCoroutine(self.space, state=self)
         self.main.subctx.framestack = None    # wack
+
+def return_main(space):
+    return AppCoroutine._get_state(space).main
+return_main.unwrap_spec = [ObjSpace]

Modified: pypy/dist/pypy/module/_stackless/test/test_pickle.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/test/test_pickle.py	(original)
+++ pypy/dist/pypy/module/_stackless/test/test_pickle.py	Sat Mar 17 14:09:31 2007
@@ -3,6 +3,19 @@
 
 # app-level testing of coroutine pickling
 
+
+class AppTestBasic:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=('_stackless',))
+
+    def test_pickle_main(self):
+        import _stackless, pickle
+        main = _stackless.coroutine.getcurrent()
+        s = pickle.dumps(main)
+        c = pickle.loads(s)
+        assert c is main
+
+
 class AppTestPickle:
 
     def setup_class(cls):



More information about the Pypy-commit mailing list