Bug 2040165 - python-cffi fails to build with Python 3.11: AssertionError - assert '\n ^^^^' == '\n File "'
Summary: python-cffi fails to build with Python 3.11: AssertionError - assert '\n ^...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-cffi
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tomáš Hrnčiar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2022-01-13 07:10 UTC by Tomáš Hrnčiar
Modified: 2022-03-30 17:47 UTC (History)
4 users (show)

Fixed In Version: python-cffi-1.15.0-5.fc37
Clone Of:
Environment:
Last Closed: 2022-03-30 17:47:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FREEIPA-7692 0 None None None 2022-01-13 07:11:11 UTC

Description Tomáš Hrnčiar 2022-01-13 07:10:27 UTC
python-cffi fails to build with Python 3.11.0a3.

=================================== FAILURES ===================================
___________________________ test_callback_exception ____________________________

    def test_callback_exception():
        try:
            import cStringIO
        except ImportError:
            import io as cStringIO    # Python 3
        import linecache
        def matches(istr, ipattern, ipattern38):
            if sys.version_info >= (3, 8):
                ipattern = ipattern38
            str, pattern = istr, ipattern
            while '$' in pattern:
                i = pattern.index('$')
                assert str[:i] == pattern[:i]
                j = str.find(pattern[i+1], i)
                assert i + 1 <= j <= str.find('\n', i)
                str = str[j:]
                pattern = pattern[i+1:]
            assert str == pattern
            return True
        def check_value(x):
            if x == 10000:
                raise ValueError(42)
        def Zcb1(x):
            check_value(x)
            return x * 3
        BShort = new_primitive_type("short")
        BFunc = new_function_type((BShort,), BShort, False)
        f = callback(BFunc, Zcb1, -42)
        #
        seen = []
        oops_result = None
        def oops(*args):
            seen.append(args)
            return oops_result
        ff = callback(BFunc, Zcb1, -42, oops)
        #
        orig_stderr = sys.stderr
        orig_getline = linecache.getline
        try:
            linecache.getline = lambda *args: 'LINE'    # hack: speed up PyPy tests
            sys.stderr = cStringIO.StringIO()
            if hasattr(sys, '__unraisablehook__'):          # work around pytest
                sys.unraisablehook = sys.__unraisablehook__ # on recent CPythons
            assert f(100) == 300
            assert sys.stderr.getvalue() == ''
            assert f(10000) == -42
>           assert matches(sys.stderr.getvalue(), """\
    From cffi callback <function$Zcb1 at 0x$>:
    Traceback (most recent call last):
      File "$", line $, in Zcb1
        $
      File "$", line $, in check_value
        $
    ValueError: 42
    """, """\
    Exception ignored from cffi callback <function$Zcb1 at 0x$>:
    Traceback (most recent call last):
      File "$", line $, in Zcb1
        $
      File "$", line $, in check_value
        $
    ValueError: 42
    """)

c/test_c.py:1374: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

istr = 'Exception ignored from cffi callback <function test_callback_exception.<locals>.Zcb1 at 0x7f18c40b94e0>:\nTraceback (...i-1.15.0/c/test_c.py", line 1349, in check_value\n    raise ValueError(42)\n    ^^^^^^^^^^^^^^^^^^^^\nValueError: 42\n'
ipattern = 'Exception ignored from cffi callback <function$Zcb1 at 0x$>:\nTraceback (most recent call last):\n  File "$", line $, in Zcb1\n    $\n  File "$", line $, in check_value\n    $\nValueError: 42\n'
ipattern38 = 'Exception ignored from cffi callback <function$Zcb1 at 0x$>:\nTraceback (most recent call last):\n  File "$", line $, in Zcb1\n    $\n  File "$", line $, in check_value\n    $\nValueError: 42\n'

    def matches(istr, ipattern, ipattern38):
        if sys.version_info >= (3, 8):
            ipattern = ipattern38
        str, pattern = istr, ipattern
        while '$' in pattern:
            i = pattern.index('$')
>           assert str[:i] == pattern[:i]
E           assert '\n    ^^^^' == '\n  File "'
E               
E             -   File "
E             +     ^^^^

c/test_c.py:1340: AssertionError

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/03142518-python-cffi/

For all our attempts to build python-cffi with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-cffi/

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.

Comment 1 Miro Hrončok 2022-01-13 11:11:37 UTC
Seems like a new form of a traceback that includes more information. Tomáš, could you please update the test upstream if not already done? It already has "if sys.version_info >= (3, 8):". I can help if needed. Thanks.

https://foss.heptapod.net/pypy/cffi

Comment 2 Tomáš Hrnčiar 2022-01-24 08:30:36 UTC
Upstream PR: https://foss.heptapod.net/pypy/cffi/-/merge_requests/111

Comment 3 Tomáš Hrnčiar 2022-02-02 08:43:56 UTC
PR: https://src.fedoraproject.org/rpms/python-cffi/pull-request/14

Comment 4 Miro Hrončok 2022-02-03 15:44:07 UTC
Fix merged but not build in Fedora because of bz2046865.

Comment 5 Fedora Update System 2022-03-30 17:42:16 UTC
FEDORA-2022-a41682259c has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-a41682259c

Comment 6 Fedora Update System 2022-03-30 17:43:50 UTC
FEDORA-2022-a41682259c has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 7 Miro Hrončok 2022-03-30 17:47:50 UTC
Ignore me, wrong bugzilla.


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