Skip to content

Python 3.13.0b1: SystemError: Objects/abstract.c:430: bad argument to internal function #365

Closed
@hroncok

Description

@hroncok

Hello. We see 3 test failures in Fedora when we try to build pycairo with Python 3.13.0b1.

I reproduced the failures in #364

============================= test session starts ==============================
platform linux -- Python 3.13.0b1, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/runner/work/pycairo/pycairo
configfile: pyproject.toml
plugins: hypothesis-6.103.0
collected 282 items / 2 skipped
tests/test_api.py ...............FF                                      [  6%]
tests/test_cmod.py .                                                     [  6%]
tests/test_context.py .................................................. [ 24%]
.................s                                                       [ 30%]
tests/test_device.py ...........                                         [ 34%]
tests/test_enums.py .......                                              [ 36%]
tests/test_error.py ....                                                 [ 38%]
tests/test_font.py sssss..............................                   [ 50%]
tests/test_glyph.py ..                                                   [ 51%]
tests/test_hypothesis.py ...........                                     [ 55%]
tests/test_matrix.py ...........                                         [ 59%]
tests/test_path.py ....                                                  [ 60%]
tests/test_pattern.py ..............................s                    [ 71%]
tests/test_rectangle.py ...                                              [ 72%]
tests/test_region.py ...........                                         [ 76%]
tests/test_surface.py ...............s.......................F.......... [ 94%]
...........s                                                             [ 98%]
tests/test_textcluster.py .                                              [ 98%]
tests/test_textextents.py ..                                             [ 99%]
tests/test_typing.py .                                                   [100%]
=================================== 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: 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: 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: 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 - SystemError: Objects/abstract.c:430: bad argument to internal function
FAILED tests/test_api.py::test_surface_mime_data_for_pdf - SystemError: Objects/abstract.c:430: bad argument to internal function
FAILED tests/test_surface.py::test_surface_get_set_mime_data - SystemError: Objects/abstract.c:430: bad argument to internal function
================== 3 failed, 270 passed, 11 skipped in 24.83s ==================

Not sure if this is a CPython bug or a problem in pycairo. Will try to investigate later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions