Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.14: test_ki_protection_doesnt_leave_cyclic_garbage fails #3209

Open
musicinmybrain opened this issue Feb 13, 2025 · 6 comments
Open

Comments

@musicinmybrain
Copy link
Contributor

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.

@musicinmybrain
Copy link
Contributor Author

It looks like this may be caused by python/cpython#125603.

@musicinmybrain
Copy link
Contributor Author

It looks like this may be caused by python/cpython#125603.

A proposed fix exists in python/cpython#125640, so this may be solved upstream in CPython before 3.14.0 final.

@A5rocks
Copy link
Contributor

A5rocks commented Feb 13, 2025

Well hopefully we don't need to do anything! (maybe we should drop the dependency on orjson? it seems to just be to load mypy cache faster -- though it's fine to manually override like you did)

@CoolCat467
Copy link
Member

It's supposed to be mypy[fastercache], but fails on pypi because orjson is programmed in rust and uses the C api

@jakkdl
Copy link
Member

jakkdl commented Feb 14, 2025

if that's the only fail I think it's time we add a <3.14 specifier to orjson and xfail(sys.version_info>=(3,14), strict=True) to the test and start running 3.14 in CI 🚀

edit: probably a bunch of the --run-slow too due to tooling being behind, but we all love to maintain those :))

@musicinmybrain
Copy link
Contributor Author

if that's the only fail I think it's time we add a <3.14 specifier to orjson and xfail(sys.version_info>=(3,14), strict=True) to the test and start running 3.14 in CI 🚀

How does #3211 look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants