Author: marky1991 Branch: py3.3 Changeset: r81704:1ea59f14a46a Date: 2015-12-30 17:45 -0500 http://bitbucket.org/pypy/pypy/changeset/1ea59f14a46a/
Log: Fix many many pickle-related failures. The changes to frozen_importlib are questionable and might be wrong. (Once you replace __import__ with import_with_frames_removed, when we try to pickle __import__ it fails to find a function with name __import__, causing pickling to fail.) Because unbound methods bacame regular functions in python3, pickling them triggers save_global, which fails because they're obviously not globals. Thus, I changed pickle.py to just use the function's __reduce/reduce_ex__ methods as they do in the default branch. 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 @@ -292,10 +292,15 @@ # Check the type dispatch table t = type(obj) - f = self.dispatch.get(t) - if f: - f(self, obj) # Call unbound method with explicit self - return + #Unbound methods no longer exist, but pyframes rely on being + #able to pickle unbound methods + #This is a pypy-specific requirement, thus the change in the stdlib + is_unbound_method = t == FunctionType and "." in obj.__qualname__ + if not is_unbound_method: + f = self.dispatch.get(t) + if f: + f(self, obj) # Call unbound method with explicit self + return # Check private dispatch table if any, or else copyreg.dispatch_table reduce = getattr(self, 'dispatch_table', dispatch_table).get(t) diff --git a/pypy/module/_frozen_importlib/__init__.py b/pypy/module/_frozen_importlib/__init__.py --- a/pypy/module/_frozen_importlib/__init__.py +++ b/pypy/module/_frozen_importlib/__init__.py @@ -30,7 +30,7 @@ space.wrap(space.builtin)) code_w.exec_code(space, self.w_dict, self.w_dict) - self.w_import = space.wrap(interp_import.import_with_frames_removed) + self.w_import = space.wrap(interp_import.__import__) def startup(self, space): """Copy our __import__ to builtins.""" diff --git a/pypy/module/_frozen_importlib/interp_import.py b/pypy/module/_frozen_importlib/interp_import.py --- a/pypy/module/_frozen_importlib/interp_import.py +++ b/pypy/module/_frozen_importlib/interp_import.py @@ -2,7 +2,7 @@ from pypy.interpreter.error import OperationError @interp2app -def import_with_frames_removed(space, __args__): +def __import__(space, __args__): try: return space.call_args( space.getbuiltinmodule('_frozen_importlib').getdictvalue( _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit