[pypy-commit] pypy py3.5: Remove PyPy-only FunctionType special case from lib-python/3/pickle.py. It shouldn't be necessary after e8b1e5c2b023. Also it was outdated.

mjacob pypy.commits at gmail.com
Wed Mar 1 19:53:06 EST 2017


Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.5
Changeset: r90449:d775ef7a4405
Date: 2017-03-02 01:52 +0100
http://bitbucket.org/pypy/pypy/changeset/d775ef7a4405/

Log:	Remove PyPy-only FunctionType special case from lib-
	python/3/pickle.py. It shouldn't be necessary after e8b1e5c2b023.
	Also it was outdated.

diff --git a/lib-python/3/pickle.py b/lib-python/3/pickle.py
--- a/lib-python/3/pickle.py
+++ b/lib-python/3/pickle.py
@@ -868,29 +868,6 @@
             return None
         return getattr, (themodule, '__dict__')
 
-    def save_function(self, obj):
-        try:
-            return self.save_global(obj)
-        except PicklingError:
-            pass
-        # Check copy_reg.dispatch_table
-        reduce = dispatch_table.get(type(obj))
-        if reduce:
-            rv = reduce(obj)
-        else:
-            # Check for a __reduce_ex__ method, fall back to __reduce__
-            reduce = getattr(obj, "__reduce_ex__", None)
-            if reduce:
-                rv = reduce(self.proto)
-            else:
-                reduce = getattr(obj, "__reduce__", None)
-                if reduce:
-                    rv = reduce()
-                else:
-                    raise e
-        return self.save_reduce(obj=obj, *rv)
-    dispatch[FunctionType] = save_function
-
     def save_set(self, obj):
         save = self.save
         write = self.write
@@ -1013,6 +990,7 @@
             return self.save_reduce(type, (...,), obj=obj)
         return self.save_global(obj)
 
+    dispatch[FunctionType] = save_global
     dispatch[type] = save_type
 
 


More information about the pypy-commit mailing list