python-cloudpickle fails to build with Python 3.11.0a5. =================================== FAILURES =================================== ___________________________ CloudPickleTest.test_abc ___________________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_abc> def test_abc(self): class AbstractClass(abc.ABC): @abc.abstractmethod def some_method(self): """A method""" @classmethod @abc.abstractmethod def some_classmethod(cls): """A classmethod""" @staticmethod @abc.abstractmethod def some_staticmethod(): """A staticmethod""" class ConcreteClass(AbstractClass): def some_method(self): return 'it works!' @classmethod def some_classmethod(cls): assert cls == ConcreteClass return 'it works!' @staticmethod def some_staticmethod(): return 'it works!' # This abstract class is locally defined so we can safely register # tuple in it to verify the unpickled class also register tuple. AbstractClass.register(tuple) concrete_instance = ConcreteClass() > depickled_base = pickle_depickle(AbstractClass, protocol=self.protocol) tests/cloudpickle_test.py:1205: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <class 'tests.cloudpickle_test.CloudPickleTest.test_abc.<locals>.AbstractClass'> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ____________________ CloudPickleTest.test_bound_classmethod ____________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_bound_classmethod> def test_bound_classmethod(self): class A: @classmethod def test_cm(cls): return "cm" > A.test_cm = pickle_depickle(A.test_cm, protocol=self.protocol) tests/cloudpickle_test.py:511: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <bound method CloudPickleTest.test_bound_classmethod.<locals>.A.test_cm of <class 'tests.cloudpickle_test.CloudPickleTest.test_bound_classmethod.<locals>.A'>> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError _______________________ CloudPickleTest.test_classmethod _______________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_classmethod> def test_classmethod(self): class A(object): @staticmethod def test_sm(): return "sm" @classmethod def test_cm(cls): return "cm" sm = A.__dict__["test_sm"] cm = A.__dict__["test_cm"] > A.test_sm = pickle_depickle(sm, protocol=self.protocol) tests/cloudpickle_test.py:499: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <staticmethod(<function CloudPickleTest.test_classmethod.<locals>.A.test_sm at 0x7ff44c8c56c0>)> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError _______ CloudPickleTest.test_closure_interacting_with_a_global_variable ________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_closure_interacting_with_a_global_variable> def test_closure_interacting_with_a_global_variable(self): global _TEST_GLOBAL_VARIABLE assert _TEST_GLOBAL_VARIABLE == "default_value" orig_value = _TEST_GLOBAL_VARIABLE try: def f0(): global _TEST_GLOBAL_VARIABLE _TEST_GLOBAL_VARIABLE = "changed_by_f0" def f1(): return _TEST_GLOBAL_VARIABLE # pickle f0 and f1 inside the same pickle_string > cloned_f0, cloned_f1 = pickle_depickle([f0, f1], protocol=self.protocol) tests/cloudpickle_test.py:1596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = [<function CloudPickleTest.test_closure_interacting_with_a_global_variable.<locals>.f0 at 0x7ff44c8c5620>, <function CloudPickleTest.test_closure_interacting_with_a_global_variable.<locals>.f1 at 0x7ff44c8c5e40>] protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ________________ CloudPickleTest.test_closure_none_is_preserved ________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_closure_none_is_preserved> def test_closure_none_is_preserved(self): def f(): """a function with no closure cells """ self.assertTrue( f.__closure__ is None, msg='f actually has closure cells!', ) > g = pickle_depickle(f, protocol=self.protocol) tests/cloudpickle_test.py:309: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_closure_none_is_preserved.<locals>.f at 0x7ff44c8c7ec0> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ___________ CloudPickleTest.test_cloudpickle_extract_nested_globals ____________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_cloudpickle_extract_nested_globals> def test_cloudpickle_extract_nested_globals(self): def function_factory(): def inner_function(): global _TEST_GLOBAL_VARIABLE return _TEST_GLOBAL_VARIABLE return inner_function globals_ = set(cloudpickle.cloudpickle._extract_code_globals( function_factory.__code__).keys()) assert globals_ == {'_TEST_GLOBAL_VARIABLE'} > depickled_factory = pickle_depickle(function_factory, protocol=self.protocol) tests/cloudpickle_test.py:2135: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_cloudpickle_extract_nested_globals.<locals>.function_factory at 0x7ff44c8c5760> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError _______________ CloudPickleTest.test_cycle_in_classdict_globals ________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_cycle_in_classdict_globals> def test_cycle_in_classdict_globals(self): class C(object): def it_works(self): return "woohoo!" C.C_again = C C.instance_of_C = C() > depickled_C = pickle_depickle(C, protocol=self.protocol) tests/cloudpickle_test.py:382: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <class 'tests.cloudpickle_test.CloudPickleTest.test_cycle_in_classdict_globals.<locals>.C'> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ________________________ CloudPickleTest.test_dataclass ________________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_dataclass> def test_dataclass(self): dataclasses = pytest.importorskip("dataclasses") DataClass = dataclasses.make_dataclass('DataClass', [('x', int)]) data = DataClass(x=42) > pickle_depickle(DataClass, protocol=self.protocol) tests/cloudpickle_test.py:1984: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <class 'types.DataClass'>, protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError _________ CloudPickleTest.test_deterministic_pickle_bytes_for_function _________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_deterministic_pickle_bytes_for_function> @pytest.mark.skipif( sys.version_info < (3, 7), reason="Determinism can only be guaranteed for Python 3.7+" ) def test_deterministic_pickle_bytes_for_function(self): # Ensure that functions with references to several global names are # pickled to fixed bytes that do not depend on the PYTHONHASHSEED of # the Python process. vals = set() def func_with_globals(): return _TEST_GLOBAL_VARIABLE + _TEST_GLOBAL_VARIABLE2 for i in range(5): vals.add( > subprocess_pickle_string(func_with_globals, protocol=self.protocol, add_env={"PYTHONHASHSEED": str(i)})) tests/cloudpickle_test.py:2602: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input_data = <function CloudPickleTest.test_deterministic_pickle_bytes_for_function.<locals>.func_with_globals at 0x7ff44c954400> protocol = 5, timeout = 60, add_env = {'PYTHONHASHSEED': '0'} def subprocess_pickle_string(input_data, protocol=None, timeout=TIMEOUT, add_env=None): """Retrieve pickle string of an object generated by a child Python process Pickle the input data into a buffer, send it to a subprocess via stdin, expect the subprocess to unpickle, re-pickle that data back and send it back to the parent process via stdout for final unpickling. >>> testutils.subprocess_pickle_string([1, 'a', None], protocol=2) b'\x80\x02]q\x00(K\x01X\x01\x00\x00\x00aq\x01Ne.' """ # run then pickle_echo(protocol=protocol) in __main__: # Protect stderr from any warning, as we will assume an error will happen # if it is not empty. A concrete example is pytest using the imp module, # which is deprecated in python 3.8 cmd = [sys.executable, '-W ignore', __file__, "--protocol", str(protocol)] cwd, env = _make_cwd_env() if add_env: env.update(add_env) proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd, env=env, bufsize=4096) pickle_string = dumps(input_data, protocol=protocol) try: comm_kwargs = {} comm_kwargs['timeout'] = timeout out, err = proc.communicate(pickle_string, **comm_kwargs) if proc.returncode != 0 or len(err): message = "Subprocess returned %d: " % proc.returncode message += err.decode('utf-8') > raise RuntimeError(message) E RuntimeError: Subprocess returned 1: Traceback (most recent call last): E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 217, in <module> E pickle_echo(protocol=protocol) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 121, in pickle_echo E obj = loads(input_bytes) E ^^^^^^^^^^^^^^^^^^ E TypeError: code expected at least 18 arguments, got 16 tests/testutils.py:71: RuntimeError _____________________ CloudPickleTest.test_dynamic_module ______________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_dynamic_module> def test_dynamic_module(self): mod = types.ModuleType('mod') code = ''' x = 1 def f(y): return x + y class Foo: def method(self, x): return f(x) ''' exec(textwrap.dedent(code), mod.__dict__) > mod2 = pickle_depickle(mod, protocol=self.protocol) tests/cloudpickle_test.py:543: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <module 'mod'>, protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError _________ CloudPickleTest.test_dynamic_module_with_unpicklable_builtin _________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_dynamic_module_with_unpicklable_builtin> def test_dynamic_module_with_unpicklable_builtin(self): # Reproducer of https://github.com/cloudpipe/cloudpickle/issues/316 # Some modules such as scipy inject some unpicklable objects into the # __builtins__ module, which appears in every module's __dict__ under # the '__builtins__' key. In such cases, cloudpickle used to fail # when pickling dynamic modules. class UnpickleableObject(object): def __reduce__(self): raise ValueError('Unpicklable object') mod = types.ModuleType("mod") exec('f = lambda x: abs(x)', mod.__dict__) assert mod.f(-1) == 1 assert '__builtins__' in mod.__dict__ unpicklable_obj = UnpickleableObject() with pytest.raises(ValueError): cloudpickle.dumps(unpicklable_obj) # Emulate the behavior of scipy by injecting an unpickleable object # into mod's builtins. # The __builtins__ entry of mod's __dict__ can either be the # __builtins__ module, or the __builtins__ module's __dict__. #316 # happens only in the latter case. if isinstance(mod.__dict__['__builtins__'], dict): mod.__dict__['__builtins__']['unpickleable_obj'] = unpicklable_obj elif isinstance(mod.__dict__['__builtins__'], types.ModuleType): mod.__dict__['__builtins__'].unpickleable_obj = unpicklable_obj > depickled_mod = pickle_depickle(mod, protocol=self.protocol) tests/cloudpickle_test.py:630: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <module 'mod'>, protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError __________________ CloudPickleTest.test_dynamic_pytest_module __________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_dynamic_pytest_module> def test_dynamic_pytest_module(self): # Test case for pull request https://github.com/cloudpipe/cloudpickle/pull/116 import py def f(): s = py.builtin.set([1]) return s.pop() # some setup is required to allow pytest apimodules to be correctly # serializable. from cloudpickle import CloudPickler from cloudpickle import cloudpickle_fast as cp_fast CloudPickler.dispatch_table[type(py.builtin)] = cp_fast._module_reduce > g = cloudpickle.loads(cloudpickle.dumps(f, protocol=self.protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:1374: TypeError _______ CloudPickleTest.test_dynamically_generated_class_that_uses_super _______ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_dynamically_generated_class_that_uses_super> def test_dynamically_generated_class_that_uses_super(self): class Base(object): def method(self): return 1 class Derived(Base): "Derived Docstring" def method(self): return super(Derived, self).method() + 1 self.assertEqual(Derived().method(), 2) # Pickle and unpickle the class. > UnpickledDerived = pickle_depickle(Derived, protocol=self.protocol) tests/cloudpickle_test.py:360: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <class 'tests.cloudpickle_test.CloudPickleTest.test_dynamically_generated_class_that_uses_super.<locals>.Derived'> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError __________________ CloudPickleTest.test_empty_cell_preserved ___________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_empty_cell_preserved> def test_empty_cell_preserved(self): def f(): if False: # pragma: no cover cell = None def g(): cell # NameError, unbound free variable return g g1 = f() with pytest.raises(NameError): g1() > g2 = pickle_depickle(g1, protocol=self.protocol) tests/cloudpickle_test.py:330: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_empty_cell_preserved.<locals>.f.<locals>.g at 0x7ff44c954e00> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ______________________ CloudPickleTest.test_extended_arg _______________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_extended_arg> def test_extended_arg(self): # Functions with more than 65535 global vars prefix some global # variable references with the EXTENDED_ARG opcode. nvars = 65537 + 258 names = ['g%d' % i for i in range(1, nvars)] r = random.Random(42) d = {name: r.randrange(100) for name in names} # def f(x): # x = g1, g2, ... # return zlib.crc32(bytes(bytearray(x))) code = """ import zlib def f(): x = {tup} return zlib.crc32(bytes(bytearray(x))) """.format(tup=', '.join(names)) exec(textwrap.dedent(code), d, d) f = d['f'] res = f() data = cloudpickle.dumps([f, f], protocol=self.protocol) d = f = None > f2, f3 = pickle.loads(data) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:1008: TypeError _____________ CloudPickleTest.test_final_or_classvar_misdetection ______________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_final_or_classvar_misdetection> def test_final_or_classvar_misdetection(self): # see https://github.com/cloudpipe/cloudpickle/issues/403 class MyClass: @property def __type__(self): return int o = MyClass() > pickle_depickle(o, protocol=self.protocol) tests/cloudpickle_test.py:2364: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <tests.cloudpickle_test.CloudPickleTest.test_final_or_classvar_misdetection.<locals>.MyClass object at 0x7ff44c79e390> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError __________________ CloudPickleTest.test_function_annotations ___________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_function_annotations> def test_function_annotations(self): def f(a: int) -> str: pass > f1 = pickle_depickle(f, protocol=self.protocol) tests/cloudpickle_test.py:2325: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_function_annotations.<locals>.f at 0x7ff44c955120> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError __________________ CloudPickleTest.test_function_module_name ___________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_function_module_name> def test_function_module_name(self): func = lambda x: x > cloned = pickle_depickle(func, protocol=self.protocol) tests/cloudpickle_test.py:1381: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_function_module_name.<locals>.<lambda> at 0x7ff44c954040> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ____________________ CloudPickleTest.test_function_qualname ____________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_function_qualname> def test_function_qualname(self): def func(x): return x # Default __qualname__ attribute (Python 3 only) if hasattr(func, '__qualname__'): > cloned = pickle_depickle(func, protocol=self.protocol) tests/cloudpickle_test.py:1389: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_function_qualname.<locals>.func at 0x7ff44c955300> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ________________________ CloudPickleTest.test_generator ________________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_generator> def test_generator(self): def some_generator(cnt): for i in range(cnt): yield i > gen2 = pickle_depickle(some_generator, protocol=self.protocol) tests/cloudpickle_test.py:482: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_generator.<locals>.some_generator at 0x7ff44c955800> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ______________________ CloudPickleTest.test_generic_type _______________________ concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib64/python3.11/concurrent/futures/process.py", line 253, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 129, in call_func func, args, kwargs = loads(payload) ^^^^^^^^^^^^^^ TypeError: code expected at least 18 arguments, got 16 """ The above exception was the direct cause of the following exception: self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_generic_type> def test_generic_type(self): T = typing.TypeVar('T') class C(typing.Generic[T]): pass assert pickle_depickle(C, protocol=self.protocol) is C # Identity is not part of the typing contract: only test for # equality instead. assert pickle_depickle(C[int], protocol=self.protocol) == C[int] with subprocess_worker(protocol=self.protocol) as worker: def check_generic(generic, origin, type_value, use_args): assert generic.__origin__ is origin if sys.version_info >= (3, 5, 3): assert len(origin.__orig_bases__) == 1 ob = origin.__orig_bases__[0] assert ob.__origin__ is typing.Generic else: # Python 3.5.[0-1-2], pragma: no cover assert len(origin.__bases__) == 1 ob = origin.__bases__[0] if use_args: assert len(generic.__args__) == 1 assert generic.__args__[0] is type_value else: assert len(generic.__parameters__) == 1 assert generic.__parameters__[0] is type_value assert len(ob.__parameters__) == 1 return "ok" # backward-compat for old Python 3.5 versions that sometimes relies # on __parameters__ use_args = getattr(C[int], '__args__', ()) != () assert check_generic(C[int], C, int, use_args) == "ok" > assert worker.run(check_generic, C[int], C, int, use_args) == "ok" tests/cloudpickle_test.py:2237: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/testutils.py:148: in run call_func, input_payload, self.protocol).result() /usr/lib64/python3.11/concurrent/futures/_base.py:444: in result return self.__get_result() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = None def __get_result(self): if self._exception: try: > raise self._exception E TypeError: code expected at least 18 arguments, got 16 /usr/lib64/python3.11/concurrent/futures/_base.py:389: TypeError _________________________ CloudPickleTest.test_import __________________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_import> def test_import(self): # like test_multiprocess except subpackage modules referenced directly # (unlike test_submodule) global etree def scope(): import xml.etree as foobar def example(): x = etree.Comment x = foobar.ElementTree return example example = scope() import xml.etree.ElementTree as etree s = cloudpickle.dumps(example, protocol=self.protocol) command = ("import base64; " "from cloudpickle.compat import pickle; " "pickle.loads(base64.b32decode('" + base64.b32encode(s).decode('ascii') + "'))()") > assert not subprocess.call([sys.executable, '-c', command]) E AssertionError: assert not 1 E + where 1 = <function call at 0x7ff44d102340>(['/usr/bin/python3', '-c', "import base64; from cloudpickle.compat import pickle; pickle.loads(base64.b32decode('QACZK...OVWGK44ULWKGQNUMCV4G23BOMV2HEZLFFZCWYZLNMVXHIVDSMVSZJBMUKKKGDDALL5PWO3DPMJQWY427L6KH3FDIBNUEC43VQ2KIMURQFY======'))()"]) E + where <function call at 0x7ff44d102340> = subprocess.call tests/cloudpickle_test.py:1096: AssertionError ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: code expected at least 18 arguments, got 16 ___________________ CloudPickleTest.test_instance_with_slots ___________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_instance_with_slots> def test_instance_with_slots(self): for slots in [["registered_attribute"], "registered_attribute"]: class ClassWithSlots(object): __slots__ = slots def __init__(self): self.registered_attribute = 42 initial_obj = ClassWithSlots() > depickled_obj = pickle_depickle( initial_obj, protocol=self.protocol) tests/cloudpickle_test.py:1953: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <tests.cloudpickle_test.CloudPickleTest.test_instance_with_slots.<locals>.ClassWithSlots object at 0x7ff44d4136d0> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ______________ CloudPickleTest.test_instancemethods_without_self _______________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_instancemethods_without_self> def test_instancemethods_without_self(self): class F(object): def f(self, x): return x + 1 > g = pickle_depickle(F.f, protocol=self.protocol) tests/cloudpickle_test.py:523: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <function CloudPickleTest.test_instancemethods_without_self.<locals>.F.f at 0x7ff44cdc4900> protocol = 5 def pickle_depickle(obj, protocol=cloudpickle.DEFAULT_PROTOCOL): """Helper function to test whether object pickled with cloudpickle can be depickled with pickle """ > return pickle.loads(cloudpickle.dumps(obj, protocol=protocol)) E TypeError: code expected at least 18 arguments, got 16 tests/cloudpickle_test.py:82: TypeError ______ CloudPickleTest.test_interactive_dynamic_type_and_remote_instances ______ source_code = 'if __name__ == "__main__":\n from testutils import subprocess_worker\n\n with subprocess_worker(protoco...ounter\n assert isinstance(c1, CustomCounter)\n assert isinstance(c2, CustomCounter)\n\n ' timeout = 60 def assert_run_python_script(source_code, timeout=TIMEOUT): """Utility to help check pickleability of objects defined in __main__ The script provided in the source code should return 0 and not print anything on stderr or stdout. """ fd, source_file = tempfile.mkstemp(suffix='_src_test_cloudpickle.py') os.close(fd) try: with open(source_file, 'wb') as f: f.write(source_code.encode('utf-8')) cmd = [sys.executable, '-W ignore', source_file] cwd, env = _make_cwd_env() kwargs = { 'cwd': cwd, 'stderr': STDOUT, 'env': env, } # If coverage is running, pass the config file to the subprocess coverage_rc = os.environ.get("COVERAGE_PROCESS_START") if coverage_rc: kwargs['env']['COVERAGE_PROCESS_START'] = coverage_rc kwargs['timeout'] = timeout try: try: > out = check_output(cmd, **kwargs) tests/testutils.py:202: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ timeout = 60 popenargs = (['/usr/bin/python3', '-W ignore', '/tmp/tmpau56hq1p_src_test_cloudpickle.py'],) kwargs = {'cwd': '/builddir/build/BUILD/cloudpickle-2.0.0', 'env': {'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare...eric -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', ...}, 'stderr': -2} kw = 'check' def check_output(*popenargs, timeout=None, **kwargs): r"""Run command with arguments and return its output. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> check_output(["ls", "-l", "/dev/null"]) b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT. >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) b'ls: non_existent_file: No such file or directory\n' There is an additional optional argument, "input", allowing you to pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it too will be used internally. Example: >>> check_output(["sed", "-e", "s/foo/bar/"], ... input=b"when in the course of fooman events\n") b'when in the course of barman events\n' By default, all communication is in bytes, and therefore any "input" should be bytes, and the return value will be bytes. If in text mode, any "input" should be a string, and the return value will be a string decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. """ for kw in ('stdout', 'check'): if kw in kwargs: raise ValueError(f'{kw} argument not allowed, it will be overridden.') if 'input' in kwargs and kwargs['input'] is None: # Explicitly passing input=None was previously equivalent to passing an # empty string. That is maintained here for backwards compatibility. if kwargs.get('universal_newlines') or kwargs.get('text'): empty = '' else: empty = b'' kwargs['input'] = empty > return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, **kwargs).stdout /usr/lib64/python3.11/subprocess.py:425: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = 60, check = True popenargs = (['/usr/bin/python3', '-W ignore', '/tmp/tmpau56hq1p_src_test_cloudpickle.py'],) kwargs = {'cwd': '/builddir/build/BUILD/cloudpickle-2.0.0', 'env': {'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare...onous-unwind-tables -fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', ...}, 'stderr': -2, 'stdout': -1} process = <Popen: returncode: 1 args: ['/usr/bin/python3', '-W ignore', '/tmp/tmpau56h...> stdout = b'concurrent.futures.process._RemoteTraceback: \n"""\nTraceback (most recent call last):\n File "/usr/lib64/python3.1...result\n raise self._exception\n ^^^^^^^^^^^^^^^^^^^^^\nTypeError: code expected at least 18 arguments, got 16\n' stderr = None, retcode = 1 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command '['/usr/bin/python3', '-W ignore', '/tmp/tmpau56hq1p_src_test_cloudpickle.py']' returned non-zero exit status 1. /usr/lib64/python3.11/subprocess.py:529: CalledProcessError The above exception was the direct cause of the following exception: self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_interactive_dynamic_type_and_remote_instances> def test_interactive_dynamic_type_and_remote_instances(self): code = """if __name__ == "__main__": from testutils import subprocess_worker with subprocess_worker(protocol={protocol}) as w: class CustomCounter: def __init__(self): self.count = 0 def increment(self): self.count += 1 return self counter = CustomCounter().increment() assert counter.count == 1 returned_counter = w.run(counter.increment) assert returned_counter.count == 2, returned_counter.count # Check that the class definition of the returned instance was # matched back to the original class definition living in __main__. assert isinstance(returned_counter, CustomCounter) # Check that memoization does not break provenance tracking: def echo(*args): return args C1, C2, c1, c2 = w.run(echo, CustomCounter, CustomCounter, CustomCounter(), returned_counter) assert C1 is CustomCounter assert C2 is CustomCounter assert isinstance(c1, CustomCounter) assert isinstance(c2, CustomCounter) """.format(protocol=self.protocol) > assert_run_python_script(code) tests/cloudpickle_test.py:1743: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ source_code = 'if __name__ == "__main__":\n from testutils import subprocess_worker\n\n with subprocess_worker(protoco...ounter\n assert isinstance(c1, CustomCounter)\n assert isinstance(c2, CustomCounter)\n\n ' timeout = 60 def assert_run_python_script(source_code, timeout=TIMEOUT): """Utility to help check pickleability of objects defined in __main__ The script provided in the source code should return 0 and not print anything on stderr or stdout. """ fd, source_file = tempfile.mkstemp(suffix='_src_test_cloudpickle.py') os.close(fd) try: with open(source_file, 'wb') as f: f.write(source_code.encode('utf-8')) cmd = [sys.executable, '-W ignore', source_file] cwd, env = _make_cwd_env() kwargs = { 'cwd': cwd, 'stderr': STDOUT, 'env': env, } # If coverage is running, pass the config file to the subprocess coverage_rc = os.environ.get("COVERAGE_PROCESS_START") if coverage_rc: kwargs['env']['COVERAGE_PROCESS_START'] = coverage_rc kwargs['timeout'] = timeout try: try: out = check_output(cmd, **kwargs) except CalledProcessError as e: > raise RuntimeError(u"script errored with output:\n%s" % e.output.decode('utf-8')) from e E RuntimeError: script errored with output: E concurrent.futures.process._RemoteTraceback: E """ E Traceback (most recent call last): E File "/usr/lib64/python3.11/concurrent/futures/process.py", line 253, in _process_worker E r = call_item.fn(*call_item.args, **call_item.kwargs) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 129, in call_func E func, args, kwargs = loads(payload) E ^^^^^^^^^^^^^^ E TypeError: code expected at least 18 arguments, got 16 E """ E E The above exception was the direct cause of the following exception: E E Traceback (most recent call last): E File "/usr/lib64/python3.11/contextlib.py", line 155, in __exit__ E self.gen.throw(typ, value, traceback) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 173, in subprocess_worker E yield worker E ^^^^^^^^^^^^ E File "/tmp/tmpau56hq1p_src_test_cloudpickle.py", line 16, in <module> E returned_counter = w.run(counter.increment) E ^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 148, in run E call_func, input_payload, self.protocol).result() E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 444, in result E return self.__get_result() E ^^^^^^^^^^^^^^^^^^^ E File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 389, in __get_result E raise self._exception E ^^^^^^^^^^^^^^^^^^^^^ E TypeError: code expected at least 18 arguments, got 16 tests/testutils.py:204: RuntimeError __ CloudPickleTest.test_interactive_dynamic_type_and_stored_remote_instances ___ source_code = 'if __name__ == "__main__":\n import cloudpickle, uuid\n from testutils import subprocess_worker\n\n ... class\n # method:\n assert w.run(lambda obj_id: lookup(obj_id).echo(43), id2) == 43\n\n ' timeout = 60 def assert_run_python_script(source_code, timeout=TIMEOUT): """Utility to help check pickleability of objects defined in __main__ The script provided in the source code should return 0 and not print anything on stderr or stdout. """ fd, source_file = tempfile.mkstemp(suffix='_src_test_cloudpickle.py') os.close(fd) try: with open(source_file, 'wb') as f: f.write(source_code.encode('utf-8')) cmd = [sys.executable, '-W ignore', source_file] cwd, env = _make_cwd_env() kwargs = { 'cwd': cwd, 'stderr': STDOUT, 'env': env, } # If coverage is running, pass the config file to the subprocess coverage_rc = os.environ.get("COVERAGE_PROCESS_START") if coverage_rc: kwargs['env']['COVERAGE_PROCESS_START'] = coverage_rc kwargs['timeout'] = timeout try: try: > out = check_output(cmd, **kwargs) tests/testutils.py:202: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ timeout = 60 popenargs = (['/usr/bin/python3', '-W ignore', '/tmp/tmpvcugzxxh_src_test_cloudpickle.py'],) kwargs = {'cwd': '/builddir/build/BUILD/cloudpickle-2.0.0', 'env': {'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare...eric -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', ...}, 'stderr': -2} kw = 'check' def check_output(*popenargs, timeout=None, **kwargs): r"""Run command with arguments and return its output. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> check_output(["ls", "-l", "/dev/null"]) b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT. >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) b'ls: non_existent_file: No such file or directory\n' There is an additional optional argument, "input", allowing you to pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it too will be used internally. Example: >>> check_output(["sed", "-e", "s/foo/bar/"], ... input=b"when in the course of fooman events\n") b'when in the course of barman events\n' By default, all communication is in bytes, and therefore any "input" should be bytes, and the return value will be bytes. If in text mode, any "input" should be a string, and the return value will be a string decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. """ for kw in ('stdout', 'check'): if kw in kwargs: raise ValueError(f'{kw} argument not allowed, it will be overridden.') if 'input' in kwargs and kwargs['input'] is None: # Explicitly passing input=None was previously equivalent to passing an # empty string. That is maintained here for backwards compatibility. if kwargs.get('universal_newlines') or kwargs.get('text'): empty = '' else: empty = b'' kwargs['input'] = empty > return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, **kwargs).stdout /usr/lib64/python3.11/subprocess.py:425: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = 60, check = True popenargs = (['/usr/bin/python3', '-W ignore', '/tmp/tmpvcugzxxh_src_test_cloudpickle.py'],) kwargs = {'cwd': '/builddir/build/BUILD/cloudpickle-2.0.0', 'env': {'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare...onous-unwind-tables -fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', ...}, 'stderr': -2, 'stdout': -1} process = <Popen: returncode: 1 args: ['/usr/bin/python3', '-W ignore', '/tmp/tmpvcugz...> stdout = b'concurrent.futures.process._RemoteTraceback: \n"""\nTraceback (most recent call last):\n File "/usr/lib64/python3.1...result\n raise self._exception\n ^^^^^^^^^^^^^^^^^^^^^\nTypeError: code expected at least 18 arguments, got 16\n' stderr = None, retcode = 1 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command '['/usr/bin/python3', '-W ignore', '/tmp/tmpvcugzxxh_src_test_cloudpickle.py']' returned non-zero exit status 1. /usr/lib64/python3.11/subprocess.py:529: CalledProcessError The above exception was the direct cause of the following exception: self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_interactive_dynamic_type_and_stored_remote_instances> def test_interactive_dynamic_type_and_stored_remote_instances(self): """Simulate objects stored on workers to check isinstance semantics Such instances stored in the memory of running worker processes are similar to dask-distributed futures for instance. """ code = """if __name__ == "__main__": import cloudpickle, uuid from testutils import subprocess_worker with subprocess_worker(protocol={protocol}) as w: class A: '''Original class definition''' pass def store(x): storage = getattr(cloudpickle, "_test_storage", None) if storage is None: storage = cloudpickle._test_storage = dict() obj_id = uuid.uuid4().hex storage[obj_id] = x return obj_id def lookup(obj_id): return cloudpickle._test_storage[obj_id] id1 = w.run(store, A()) # The stored object on the worker is matched to a singleton class # definition thanks to provenance tracking: assert w.run(lambda obj_id: isinstance(lookup(obj_id), A), id1) # Retrieving the object from the worker yields a local copy that # is matched back the local class definition this instance # originally stems from. assert isinstance(w.run(lookup, id1), A) # Changing the local class definition should be taken into account # in all subsequent calls. In particular the old instances on the # worker do not map back to the new class definition, neither on # the worker itself, nor locally on the main program when the old # instance is retrieved: class A: '''Updated class definition''' pass assert not w.run(lambda obj_id: isinstance(lookup(obj_id), A), id1) retrieved1 = w.run(lookup, id1) assert not isinstance(retrieved1, A) assert retrieved1.__class__ is not A assert retrieved1.__class__.__doc__ == "Original class definition" # New instances on the other hand are proper instances of the new # class definition everywhere: a = A() id2 = w.run(store, a) assert w.run(lambda obj_id: isinstance(lookup(obj_id), A), id2) assert isinstance(w.run(lookup, id2), A) # Monkeypatch the class defintion in the main process to a new # class method: A.echo = lambda cls, x: x # Calling this method on an instance will automatically update # the remote class definition on the worker to propagate the monkey # patch dynamically. assert w.run(a.echo, 42) == 42 # The stored instance can therefore also access the new class # method: assert w.run(lambda obj_id: lookup(obj_id).echo(43), id2) == 43 """.format(protocol=self.protocol) > assert_run_python_script(code) tests/cloudpickle_test.py:1821: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ source_code = 'if __name__ == "__main__":\n import cloudpickle, uuid\n from testutils import subprocess_worker\n\n ... class\n # method:\n assert w.run(lambda obj_id: lookup(obj_id).echo(43), id2) == 43\n\n ' timeout = 60 def assert_run_python_script(source_code, timeout=TIMEOUT): """Utility to help check pickleability of objects defined in __main__ The script provided in the source code should return 0 and not print anything on stderr or stdout. """ fd, source_file = tempfile.mkstemp(suffix='_src_test_cloudpickle.py') os.close(fd) try: with open(source_file, 'wb') as f: f.write(source_code.encode('utf-8')) cmd = [sys.executable, '-W ignore', source_file] cwd, env = _make_cwd_env() kwargs = { 'cwd': cwd, 'stderr': STDOUT, 'env': env, } # If coverage is running, pass the config file to the subprocess coverage_rc = os.environ.get("COVERAGE_PROCESS_START") if coverage_rc: kwargs['env']['COVERAGE_PROCESS_START'] = coverage_rc kwargs['timeout'] = timeout try: try: out = check_output(cmd, **kwargs) except CalledProcessError as e: > raise RuntimeError(u"script errored with output:\n%s" % e.output.decode('utf-8')) from e E RuntimeError: script errored with output: E concurrent.futures.process._RemoteTraceback: E """ E Traceback (most recent call last): E File "/usr/lib64/python3.11/concurrent/futures/process.py", line 253, in _process_worker E r = call_item.fn(*call_item.args, **call_item.kwargs) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 129, in call_func E func, args, kwargs = loads(payload) E ^^^^^^^^^^^^^^ E TypeError: code expected at least 18 arguments, got 16 E """ E E The above exception was the direct cause of the following exception: E E Traceback (most recent call last): E File "/usr/lib64/python3.11/contextlib.py", line 155, in __exit__ E self.gen.throw(typ, value, traceback) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 173, in subprocess_worker E yield worker E ^^^^^^^^^^^^ E File "/tmp/tmpvcugzxxh_src_test_cloudpickle.py", line 22, in <module> E id1 = w.run(store, A()) E ^^^^^^^^^^^^^^^^^ E File "/builddir/build/BUILD/cloudpickle-2.0.0/tests/testutils.py", line 148, in run E call_func, input_payload, self.protocol).result() E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E https://docs.python.org/3.11/whatsnew/3.11.html For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/03648890-python-cloudpickle/ For all our attempts to build python-cloudpickle with Python 3.11, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-cloudpickle/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11: https://copr.fedorainfracloud.org/coprs/g/python/python3.11/ Let us know here if you have any questions. Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
Reported upstream: https://github.com/cloudpipe/cloudpickle/issues/466
Fix proposed upstream: https://github.com/cloudpipe/cloudpickle/pull/467
FEDORA-2022-39daffcabf has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-39daffcabf
FEDORA-2022-39daffcabf has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report.