Bug 2097850 - ansible-core fails to build with Python 3.11
Summary: ansible-core fails to build with Python 3.11
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: ansible-core
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2022-06-16 17:31 UTC by Miro Hrončok
Modified: 2022-06-16 18:24 UTC (History)
4 users (show)

Fixed In Version: ansible-core-2.12.6-2.fc37
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-06-16 18:24:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2022-06-16 17:31:50 UTC
With this PR:

https://src.fedoraproject.org/rpms/ansible-core/pull-request/9

We see the following test failures with Python 3.11 in the f37-python side tag:

=================================== FAILURES ===================================
______________________ test_redir_http_error_308_urllib2 _______________________
[gw5] linux -- Python 3.11.0 /usr/bin/python3
urllib_req = <urllib.request.Request object at 0xf47b1130>
request_body = <_io.StringIO object at 0xf53bd220>
    def test_redir_http_error_308_urllib2(urllib_req, request_body):
        handler = RedirectHandlerFactory('urllib2', False)
        inst = handler()

>       with pytest.raises(urllib_error.HTTPError):
E       Failed: DID NOT RAISE <class 'urllib.error.HTTPError'>
test/units/module_utils/urls/test_RedirectHandlerFactory.py:137: Failed
____________________________ test_fetch_url_cookies ____________________________
[gw4] linux -- Python 3.11.0 /usr/bin/python3
mocker = <function test_fetch_url_cookies.<locals>.make_cookies at 0xf47fc8e8>
fake_ansible_module = <units.module_utils.urls.test_fetch_url.FakeAnsibleModule object at 0xf4850070>
    def test_fetch_url_cookies(mocker, fake_ansible_module):
        def make_cookies(*args, **kwargs):
            cookies = kwargs['cookies']
            r = MagicMock()
            try:
                r.headers = HTTPMessage()
                add_header = r.headers.add_header
            except TypeError:
                # PY2
                r.headers = HTTPMessage(StringIO())
                add_header = r.headers.addheader
            r.info.return_value = r.headers
            for name, value in (('Foo', 'bar'), ('Baz', 'qux')):
                cookie = Cookie(
                    version=0,
                    name=name,
                    value=value,
                    port=None,
                    port_specified=False,
                    domain="ansible.com",
                    domain_specified=True,
                    domain_initial_dot=False,
                    path="/",
                    path_specified=True,
                    secure=False,
                    expires=None,
                    discard=False,
                    comment=None,
                    comment_url=None,
                    rest=None
                )
                cookies.set_cookie(cookie)
                add_header('Set-Cookie', '%s=%s' % (name, value))

            return r

        mocker = mocker.patch('ansible.module_utils.urls.open_url', new=make_cookies)

        r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')

        assert info['cookies'] == {'Baz': 'qux', 'Foo': 'bar'}
        # Python sorts cookies in order of most specific (ie. longest) path first
        # items with the same path are reversed from response order
>       assert info['cookies_string'] == 'Baz=qux; Foo=bar'
E       AssertionError: assert 'Foo=bar; Baz=qux' == 'Baz=qux; Foo=bar'
E         - Baz=qux; Foo=bar
E         + Foo=bar; Baz=qux
test/units/module_utils/urls/test_fetch_url.py:138: AssertionError
- generated xml file: /builddir/build/BUILD/ansible-core-2.12.6/test/results/junit/python3.11-module_utils-units.xml -


Hence, we cannot rebuild ansible for Python 3.11.

Comment 1 Miro Hrončok 2022-06-16 17:35:52 UTC
test_fetch_url_cookies seems like a bad order issue, I suggest we can skip the test for now.


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