Bug 2264851

Summary: pycairo fails to build with Python 3.13: SystemError: /builddir/build/BUILD/Python-3.13.0a4/Objects/abstract.c:430: bad argument to internal function
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: pycairoAssignee: Kalev Lember <klember>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, dan, gnome-sig, klember, ksurma, mclasen, mhroncok, rhughes, rstrode
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pycairo-1.25.1-4.fc41 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-19 00:28:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2244836    

Description Karolina Surma 2024-02-19 10:02:41 UTC
pycairo fails to build with Python 3.13.0a4.

=================================== FAILURES ===================================
__________________ test_surface_get_set_mime_data_references ___________________

    @pytest.mark.skipif(not hasattr(sys, "getrefcount"), reason="PyPy")
    def test_surface_get_set_mime_data_references():
        surface = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1)
        v = memoryview(b"bla")
        x = v[:1]
        recfcount_v = sys.getrefcount(v)
        recfcount_x = sys.getrefcount(x)
        assert recfcount_v == recfcount_x
>       surface.set_mime_data("foo", v)
E       SystemError: /builddir/build/BUILD/Python-3.13.0a4/Objects/abstract.c:430: bad argument to internal function

tests/test_api.py:282: SystemError
________________________ test_surface_mime_data_for_pdf ________________________

    @pytest.mark.skipif(
        sysconfig.get_platform().startswith("win"), reason="msvc fixme")
    def test_surface_mime_data_for_pdf():
        jpeg_bytes = zlib.decompress(base64.b64decode(
            b'eJz7f+P/AwYBLzdPNwZGRkYGDyBk+H+bwRnEowj8P8TAzcHACDJHkOH/EQYRIBsV'
            b'cP6/xcDBCBJlrLcHqRBAV8EAVcHIylSPVwGbPQEFjPaK9XDrBAipBSq4CQB9jiS0'
        ))
    
        file_like = io.BytesIO()
        surface = cairo.PDFSurface(file_like, 3, 3)
        context = cairo.Context(surface)
        image = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1)
>       image.set_mime_data(cairo.MIME_TYPE_JPEG, jpeg_bytes)
E       SystemError: /builddir/build/BUILD/Python-3.13.0a4/Objects/abstract.c:430: bad argument to internal function

tests/test_api.py:308: SystemError
________________________ test_surface_get_set_mime_data ________________________

    def test_surface_get_set_mime_data():
        surface = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1)
        assert surface.get_mime_data("foo") is None
        assert surface.get_mime_data(cairo.MIME_TYPE_JPEG) is None
    
>       surface.set_mime_data("foo", b"bar")
E       SystemError: /builddir/build/BUILD/Python-3.13.0a4/Objects/abstract.c:430: bad argument to internal function

tests/test_surface.py:478: SystemError
=========================== short test summary info ============================
FAILED tests/test_api.py::test_surface_get_set_mime_data_references - SystemE...
FAILED tests/test_api.py::test_surface_mime_data_for_pdf - SystemError: /buil...
FAILED tests/test_surface.py::test_surface_get_set_mime_data - SystemError: /...
=================== 3 failed, 268 passed, 3 skipped in 0.48s ===================
https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/07033691-pycairo/

For all our attempts to build pycairo with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/pycairo/

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.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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 2024-05-29 15:06:11 UTC
This is blocking pygobject3, which is blocking 100+ other packages.

Comment 2 Miro Hrončok 2024-05-29 15:11:02 UTC
Updating to 1.26.0 does not help.

Comment 3 Miro Hrončok 2024-05-29 15:20:35 UTC
Reported upstream at https://github.com/pygobject/pycairo/issues/365

Comment 4 Miro Hrončok 2024-05-29 17:37:56 UTC
(In reply to Miro Hrončok from comment #1)
> This is blocking pygobject3, which is blocking 100+ other packages.

Also transitively blocks python-pillow which is needed by 200+.