Python 3.14: test_ki_protection_doesnt_leave_cyclic_garbage fails
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.
It looks like this may be caused by https://github.com/python/cpython/issues/125603.
It looks like this may be caused by python/cpython#125603.
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.
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)
It's supposed to be mypy[fastercache], but fails on pypi because orjson is programmed in rust and uses the C api
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 :))
if that's the only fail I think it's time we add a
<3.14specifier to orjson andxfail(sys.version_info>=(3,14), strict=True)to the test and start running 3.14 in CI 🚀
How does https://github.com/python-trio/trio/pull/3211 look?
I'm going to merge this into https://github.com/python-trio/trio/issues/3267 as a centralized tracking issue