in odps/lib/cloudpickle.py [0:0]
def load_reduce(self):
# Replace the internal implementation of pickle
# cause code representation in Python 3 differs from that in Python 2
stack = self.stack
args = stack.pop()
func = stack[-1]
if self._src_version is not None:
if func.__name__ == 'code':
if sys.version_info[:2] == (2, 7):
if self._src_version >= (3, 6): # src >= PY36, dest PY27
args = Cp36_Cp35(args).translate_code()
args = Cp35_Cp27(args).translate_code()
elif self._src_major == 3 and self._src_version <= (3, 5): # src PY3 && src <= PY35, dest PY27
args = Cp35_Cp27(args).translate_code()
elif not hasattr(sys, "pypy_version_info") and self._src_impl == 'pypy':
args = Pypy2_Cp27(args).translate_code()
elif sys.version_info[:2] == (3, 7):
if self._src_version == (3, 10):
args = Cp310_Cp39(args).translate_code()
args = Cp39_Cp37(args).translate_code()
elif self._src_version == (3, 9):
args = Cp39_Cp37(args).translate_code()
elif self._src_version == (3, 8):
args = Cp38_Cp37(args).translate_code()
elif self._src_version == (3, 6):
args = Cp36_Cp37(args).translate_code()
elif self._src_version != (3, 7):
raise SystemError(
"Client Python version not acceptable, please use Python 3.7 to run your code"
)
elif sys.version_info[:2] != self._src_version:
raise NotImplementedError('Code conversion from Python %r to %r is not supported yet.'
% (self._src_version, sys.version_info[:2]))
if self._dump_code:
print(args[9 if not PY3 else 10])
dis.dis(args[4 if not PY3 else 5])
sys.stdout.flush()
elif func.__name__ == 'type' or func.__name__ == 'classobj' or (
isinstance(func, type) and issubclass(func, type)):
if not PY3:
args = list(args)
args[0] = args[0].encode('utf-8') if isinstance(args[0], unicode) else args[0]
try:
value = func(*args)
except Exception as exc:
traceback.print_exc()
raise Exception('Failed to unpickle reduce. func=%s mod=%s args=%s msg="%s"' % (
func.__name__, func.__module__, repr(args), str(exc)))
stack[-1] = value