[pypy-svn] r64094 - in pypy/branch/wip-fix-stackless-O2-pickling/pypy: interpreter module/_stackless/test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Apr 15 13:40:27 CEST 2009


Author: cfbolz
Date: Wed Apr 15 13:40:24 2009
New Revision: 64094

Modified:
   pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/function.py
   pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/_stackless/test/test_pickle_infrastructure.py
Log:
(pedronis, cfbolz): Fix reduce function of functions to not make tuples that
contain interp-level Nones.


Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/function.py	(original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/function.py	Wed Apr 15 13:40:24 2009
@@ -205,19 +205,32 @@
             w_closure = space.w_None
         else:
             w_closure = space.newtuple([w(cell) for cell in self.closure])
+        if self.w_doc is None:
+            w_doc = space.w_None
+        else:
+            w_doc = self.w_doc
+        if self.w_func_globals is None:
+            w_func_globals = space.w_None
+        else:
+            w_func_globals = self.w_func_globals
+        if self.w_func_dict is None:
+            w_func_dict = space.w_None
+        else:
+            w_func_dict = self.w_func_dict
 
         nt = space.newtuple
         tup_base = []
         tup_state = [
             w(self.name),
-            self.w_doc,
+            w_doc,
             w(self.code),
-            self.w_func_globals,
+            w_func_globals,
             w_closure,
             nt(self.defs_w[:]),
-            self.w_func_dict,
+            w_func_dict,
             self.w_module,
         ]
+        print tup_state
         return nt([new_inst, nt(tup_base), nt(tup_state)])
 
     def descr_function__setstate__(self, space, w_args):
@@ -228,17 +241,24 @@
 
         self.space = space
         self.name = space.str_w(w_name)
-        self.w_doc = w_doc
         self.code = space.interp_w(Code, w_code)
         self.w_func_globals = w_func_globals
-        if w_closure is not space.w_None:
+        if not space.is_w(w_closure, space.w_None):
             from pypy.interpreter.nestedscope import Cell
             closure_w = space.unpackiterable(w_closure)
             self.closure = [space.interp_w(Cell, w_cell) for w_cell in closure_w]
         else:
             self.closure = None
-        self.defs_w    = space.unpackiterable(w_defs_w)
+        if not space.is_w(w_doc, space.w_None):
+            w_doc = None
+        self.w_doc = w_doc
+        if not space.is_w(w_func_globals, space.w_None):
+            w_func_globals = None
+        self.w_func_globals = w_func_globals
+        if not space.is_w(w_func_dict, space.w_None):
+            w_func_dict = None
         self.w_func_dict = w_func_dict
+        self.defs_w    = space.unpackiterable(w_defs_w)
         self.w_module = w_module
 
     def fget_func_defaults(space, self):

Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/_stackless/test/test_pickle_infrastructure.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/_stackless/test/test_pickle_infrastructure.py	(original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/_stackless/test/test_pickle_infrastructure.py	Wed Apr 15 13:40:24 2009
@@ -17,6 +17,8 @@
 
         # xxx identity preservation for the function would be better
         assert res.func_code is sw.func_code
+        assert res.func_doc is sw.func_doc
+        assert res.func_globals is sw.func_globals
         
 class AppTestPicklePrerequisites(BaseAppTestPicklePrerequisites):
     pass



More information about the Pypy-commit mailing list