Bug 2345516

Summary: python-trio fails to build with Python 3.14: test_ki_protection_doesnt_leave_cyclic_garbage: Left contains one more item: <coroutine object test_ki_protection_doesnt_leave_cyclic_garbage at 0x7fbaa2f162c0>
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-trioAssignee: Ben Beasley <code>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: carl, code, ksurma, mhroncok, python-packagers-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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: 2322407    

Description Karolina Surma 2025-02-13 11:07:18 UTC
python-trio fails to build with Python 3.14.05.

________________ test_ki_protection_doesnt_leave_cyclic_garbage ________________

    @pytest.mark.skipif(
        sys.implementation.name != "cpython",
        reason="Only makes sense with refcounting GC",
    )
    async def test_ki_protection_doesnt_leave_cyclic_garbage() -> None:
        class MyException(Exception):
            pass
    
        async def demo() -> None:
            async def handle_error() -> None:
                try:
                    raise MyException
                except MyException as e:
                    exceptions.append(e)
    
            exceptions: list[MyException] = []
            try:
                async with _core.open_nursery() as n:
                    n.start_soon(handle_error)
                raise ExceptionGroup("errors", exceptions)
            finally:
                exceptions = []
    
        exc: Exception | None = None
        try:
            await demo()
        except ExceptionGroup as excs:
            exc = excs.exceptions[0]
    
        assert isinstance(exc, MyException)
>       assert gc.get_referrers(exc) == no_other_refs()
E       assert [<coroutine o...7fbaa2f162c0>] == []
E         
E         Left contains one more item: <coroutine object test_ki_protection_doesnt_leave_cyclic_garbage at 0x7fbaa2f162c0>
E         
E         Full diff:
E         - []
E         + [
E         +     <coroutine object test_ki_protection_doesnt_leave_cyclic_garbage at 0x7fbaa2f162c0>,
E         + ]

https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08651119-python-trio/

For all our attempts to build python-trio with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-trio/

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

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
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 Ben Beasley 2025-02-13 16:54:00 UTC
Reproduced in a virtualenv and reported upstream: https://github.com/python-trio/trio/issues/3209

Comment 2 Ben Beasley 2025-02-13 16:56:07 UTC
This appears to be caused by https://github.com/python/cpython/issues/125603.

Comment 3 Ben Beasley 2025-02-13 16:57:35 UTC
A proposed fix exists in https://github.com/python/cpython/pull/125640, so this may be solved upstream in CPython before 3.14.0 final.

Comment 4 Ben Beasley 2025-02-13 16:59:08 UTC
Assigning this to myself since I’m now keeping an eye on the CPython issue.

Comment 5 Ben Beasley 2025-02-13 19:15:13 UTC
Upon reflection, I think it would make sense to skip this test on Python 3.14 for the time being, since it seems clear that the issue is in CPython and that it is breaking the *test*, not the *implementation*.

https://src.fedoraproject.org/rpms/python-trio/pull-request/10

Comment 6 Karolina Surma 2025-05-21 12:39:06 UTC
And with beta1 we're having even more fun in trio: 

_core/_tests/test_run.py::test_error_in_run_loop Fatal Python error: Segmentation fault