[pypy-svn] r77820 - pypy/branch/fast-forward/lib-python/modified-2.7.0/multiprocessing

afa at codespeak.net afa at codespeak.net
Tue Oct 12 12:56:03 CEST 2010


Author: afa
Date: Tue Oct 12 12:56:01 2010
New Revision: 77820

Added:
   pypy/branch/fast-forward/lib-python/modified-2.7.0/multiprocessing/
      - copied from r77812, pypy/branch/fast-forward/lib-python/2.7.0/multiprocessing/
Modified:
   pypy/branch/fast-forward/lib-python/modified-2.7.0/multiprocessing/forking.py
Log:
PyPy does not have a separate type for builtin methods:
list.append is a regular unbound method, with im_func & co.

(this fix means that complex objects are being transferred between processes.
Progress!)


Modified: pypy/branch/fast-forward/lib-python/modified-2.7.0/multiprocessing/forking.py
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/multiprocessing/forking.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/multiprocessing/forking.py	Tue Oct 12 12:56:01 2010
@@ -47,15 +47,12 @@
         return getattr, (m.im_self, m.im_func.func_name)
 ForkingPickler.register(type(ForkingPickler.save), _reduce_method)
 
-def _reduce_method_descriptor(m):
-    return getattr, (m.__objclass__, m.__name__)
-ForkingPickler.register(type(list.append), _reduce_method_descriptor)
-ForkingPickler.register(type(int.__add__), _reduce_method_descriptor)
-
-#def _reduce_builtin_function_or_method(m):
-#    return getattr, (m.__self__, m.__name__)
-#ForkingPickler.register(type(list().append), _reduce_builtin_function_or_method)
-#ForkingPickler.register(type(int().__add__), _reduce_builtin_function_or_method)
+if type(list.append) is not type(ForkingPickler.save):
+    # Some python implementations have unbound methods even for builtin types
+    def _reduce_method_descriptor(m):
+        return getattr, (m.__objclass__, m.__name__)
+    ForkingPickler.register(type(list.append), _reduce_method_descriptor)
+    ForkingPickler.register(type(int.__add__), _reduce_method_descriptor)
 
 try:
     from functools import partial



More information about the Pypy-commit mailing list