Bug 1958163 - python-cloudpickle fails to build with Python 3.10: AssertionError: assert <class 'tests...t.<locals>.C'> == 'type_' <class 'tests.cloudpickle_test._all_types_to_test.<locals>.C'> -'type_'
Summary: python-cloudpickle fails to build with Python 3.10: AssertionError: assert <c...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-cloudpickle
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lumír Balhar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2021-05-07 11:21 UTC by Tomáš Hrnčiar
Modified: 2021-05-10 09:38 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-10 09:38:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-05-07 11:21:59 UTC
python-cloudpickle fails to build with Python 3.10.0b1.

=================================== FAILURES ===================================
__________ CloudPickleTest.test_locally_defined_class_with_type_hints __________

self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_locally_defined_class_with_type_hints>

    def test_locally_defined_class_with_type_hints(self):
        with subprocess_worker(protocol=self.protocol) as worker:
            for type_ in _all_types_to_test():
                class MyClass:
                    def method(self, arg: type_) -> type_:
                        return arg
                MyClass.__annotations__ = {'attribute': type_}
    
                def check_annotations(obj, expected_type, expected_type_str):
                    assert obj.__annotations__["attribute"] == expected_type
                    if sys.version_info >= (3, 10):
                        # In Python 3.10, type annotations are stored as strings.
                        # See PEP 563 for more details: https://www.python.org/dev/peps/pep-0563/
                        assert obj.method.__annotations__["arg"] == expected_type_str
                        assert (
                            obj.method.__annotations__["return"] == expected_type_str
                        )
                    else:
                        assert obj.method.__annotations__["arg"] == expected_type
                        assert (
                            obj.method.__annotations__["return"] == expected_type
                        )
                    return "ok"
    
                obj = MyClass()
>               assert check_annotations(obj, type_, "type_") == "ok"

tests/cloudpickle_test.py:2225: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = <tests.cloudpickle_test.CloudPickleTest.test_locally_defined_class_with_type_hints.<locals>.MyClass object at 0x7fcf06dd4af0>
expected_type = <class 'tests.cloudpickle_test._all_types_to_test.<locals>.C'>
expected_type_str = 'type_'

    def check_annotations(obj, expected_type, expected_type_str):
        assert obj.__annotations__["attribute"] == expected_type
        if sys.version_info >= (3, 10):
            # In Python 3.10, type annotations are stored as strings.
            # See PEP 563 for more details: https://www.python.org/dev/peps/pep-0563/
>           assert obj.method.__annotations__["arg"] == expected_type_str
E           AssertionError: assert <class 'tests...t.<locals>.C'> == 'type_'
E             +<class 'tests.cloudpickle_test._all_types_to_test.<locals>.C'>
E             -'type_'

tests/cloudpickle_test.py:2213: AssertionError
_____ Protocol2CloudPickleTest.test_locally_defined_class_with_type_hints ______

self = <tests.cloudpickle_test.Protocol2CloudPickleTest testMethod=test_locally_defined_class_with_type_hints>

    def test_locally_defined_class_with_type_hints(self):
        with subprocess_worker(protocol=self.protocol) as worker:
            for type_ in _all_types_to_test():
                class MyClass:
                    def method(self, arg: type_) -> type_:
                        return arg
                MyClass.__annotations__ = {'attribute': type_}
    
                def check_annotations(obj, expected_type, expected_type_str):
                    assert obj.__annotations__["attribute"] == expected_type
                    if sys.version_info >= (3, 10):
                        # In Python 3.10, type annotations are stored as strings.
                        # See PEP 563 for more details: https://www.python.org/dev/peps/pep-0563/
                        assert obj.method.__annotations__["arg"] == expected_type_str
                        assert (
                            obj.method.__annotations__["return"] == expected_type_str
                        )
                    else:
                        assert obj.method.__annotations__["arg"] == expected_type
                        assert (
                            obj.method.__annotations__["return"] == expected_type
                        )
                    return "ok"
    
                obj = MyClass()
>               assert check_annotations(obj, type_, "type_") == "ok"

tests/cloudpickle_test.py:2225: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = <tests.cloudpickle_test.CloudPickleTest.test_locally_defined_class_with_type_hints.<locals>.MyClass object at 0x7fcf06c7f7c0>
expected_type = <class 'tests.cloudpickle_test._all_types_to_test.<locals>.C'>
expected_type_str = 'type_'

    def check_annotations(obj, expected_type, expected_type_str):
        assert obj.__annotations__["attribute"] == expected_type
        if sys.version_info >= (3, 10):
            # In Python 3.10, type annotations are stored as strings.
            # See PEP 563 for more details: https://www.python.org/dev/peps/pep-0563/
>           assert obj.method.__annotations__["arg"] == expected_type_str
E           AssertionError: assert <class 'tests...t.<locals>.C'> == 'type_'
E             +<class 'tests.cloudpickle_test._all_types_to_test.<locals>.C'>
E             -'type_'

tests/cloudpickle_test.py:2213: AssertionError
=============================== warnings summary ===============================
tests/cloudpickle_test.py::CloudPickleTest::test_module_importability
  /builddir/build/BUILD/cloudpickle-1.6.0/tests/cloudpickle_test.py:705: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    import distutils

tests/cloudpickle_test.py::CloudPickleTest::test_tornado_coroutine
tests/cloudpickle_test.py::CloudPickleTest::test_tornado_coroutine
tests/cloudpickle_test.py::Protocol2CloudPickleTest::test_tornado_coroutine
  /usr/lib64/python3.10/site-packages/tornado/ioloop.py:263: DeprecationWarning: There is no current event loop
    loop = asyncio.get_event_loop()

tests/cloudpickle_test.py::CloudPickleTest::test_tornado_coroutine
  /usr/lib64/python3.10/site-packages/tornado/platform/asyncio.py:279: DeprecationWarning: There is no current event loop
    super().initialize(asyncio.get_event_loop(), **kwargs)

tests/cloudpickle_test.py::CloudPickleTest::test_tornado_coroutine
tests/cloudpickle_test.py::Protocol2CloudPickleTest::test_tornado_coroutine
  /usr/lib64/python3.10/site-packages/tornado/platform/asyncio.py:193: DeprecationWarning: There is no current event loop
    old_loop = asyncio.get_event_loop()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/cloudpickle_test.py::CloudPickleTest::test_locally_defined_class_with_type_hints
FAILED tests/cloudpickle_test.py::Protocol2CloudPickleTest::test_locally_defined_class_with_type_hints
===== 2 failed, 213 passed, 13 skipped, 3 deselected, 7 warnings in 9.37s ======

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/02168085-python-cloudpickle/

For all our attempts to build python-cloudpickle with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/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.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
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.


Note You need to log in before you can comment on or make changes to this bug.