Skip to content

Python 3.14: test_ki_protection_doesnt_leave_cyclic_garbage fails #3209

@musicinmybrain

Description

@musicinmybrain

The sed command below comments out orjson from test-requirements.txt since it’s not yet installable on Python 3.14. Otherwise, this can be reproduced by simply running the tests in a Python 3.14.0a4 virtualenv:

$ git clone https://github.com/python-trio/trio.git
$ cd trio
$ uv venv _e --python 3.14
Using CPython 3.14.0a4 interpreter at: /usr/bin/python3.14
Creating virtual environment at: _e
Activate with: source _e/bin/activate
$ . _e/bin/activate
(_e) $ uv pip install -e .
(_e) $ sed -r -i 's/^orjson/# &/' test-requirements.txt
(_e) $ uv pip install -r test-requirements.txt
(_e) $ python -m pytest
[…]
============================================== FAILURES ==============================================
___________________________ 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...7f6a92bb0c40>] == []
E         
E         Left contains one more item: <coroutine object test_ki_protection_doesnt_leave_cyclic_garbage at 0x7f6a92bb0c40>
E         Use -v to get more diff

src/trio/_core/_tests/test_run.py:2846: AssertionError
====================================== short test summary info =======================================
FAILED src/trio/_core/_tests/test_run.py::test_ki_protection_doesnt_leave_cyclic_garbage - assert [<coroutine o...7f6a92bb0c40>] == []
======================== 1 failed, 766 passed, 79 skipped, 2 xfailed in 6.89s ========================

This was originally reported in Fedora.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions