Skip to content

test: match Python 3.14's finalizer warnings and report weakref callback errors - #492

Draft
d-v-b wants to merge 3 commits into
mainfrom
claude/trusting-kapitsa-e49283
Draft

d-v-b wants to merge 3 commits into
mainfrom
claude/trusting-kapitsa-e49283

Conversation

@d-v-b

@d-v-b d-v-b commented Dec 3, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

The pytest filters for leaked event loops, sockets and s3fs sessions now match the wording Python 3.14 uses for errors in finalizers. The s3fs filter no longer hides every error in a weakref callback run by the garbage collector on Python 3.14.

What changed

Only [tool.pytest.ini_options] filterwarnings in pyproject.toml changes, in two commits.

  • cd7e4f415: Python 3.14 reports an error in a finalizer as Exception ignored while ..., where earlier versions say Exception ignored in: .... The patterns now accept both.
  • 011ecf2f7: the s3fs filter had an on calling weakref callback alternative with no condition on the error. It now requires Session was never entered in all cases.
Evidence

Temporary probe tests, not part of this PR, were run on 3.12, 3.13, 3.14 and 3.14t with pytest 9.2.0.

Probe Before After
Leaked event loop and socket.socketpair() pass on 3.12 and 3.13, fail on 3.14 and 3.14t pass on all
__del__ raising "Session was never entered" pass on 3.12 and 3.13, fail on 3.14 and 3.14t pass on all
ValueError in a weakref callback run by the garbage collector hidden on 3.14, fails on the others fails on all
Unclosed file, unrelated __del__ error, UDP socket fail on all fail on all
  • The probes import tracemalloc first. Without that, the combined loop and socket leak fails on 3.12 before and after the change, because pytest's unraisable hook imports it while objects are being finalized.
  • With the s3fs filter removed, tests/test_store/test_fsspec.py fails on 3.12 and 3.14 with aiobotocore 3.9.1 and passes with the locked 3.10.0. With the new filter it passes on 3.12 and 3.14 with 3.9.1, and on 3.14 with 3.10.0.
  • The full suite passes on 3.14 with aiobotocore 3.9.1 and 3.10.0 (macOS).
  • The agent did not reproduce a loop leak in the real suite. With the old filters, one full run each on 3.12 and 3.14 passed and logged no unclosed loops. The first commit is a precaution.
Review findings

Three reviewer agents found no serious problem introduced by the branch.

  • Serious, already present: the weakref alternative hid all garbage-collected callback errors on 3.14. Fixed in 011ecf2f7.
  • Minor: imprecise comments and commit messages. Corrected before pushing.
  • Minor: the pytest-asyncio comment did not hold on 3.14, where _get_event_loop_no_warn raises instead of creating a loop. Noted in the comment in cd7e4f415.
  • Minor, accepted: an error whose text quotes a matched string is now hidden on 3.14 too, as on 3.12 and 3.13.
  • Minor, not changed: the marker in tests/test_store/test_fsspec.py (Exception ignored in.*finalize object.*) hides any finalize error on 3.12 and 3.13 and matches nothing on 3.14. Removing it was not tested.

🤖 Generated with Claude Code

d-v-b added 3 commits December 3, 2026 14:57
Python 3.14 reports an error in a finalizer as "Exception ignored while ..."
where earlier versions say "Exception ignored in: ...". The filters for leaked
event loops, sockets and s3fs sessions did not match the new wording, so on
3.14 such a leak could fail whichever test was running when it was finalized.

Assisted-by: ClaudeCode:claude-opus-5-5
The filter for s3fs sessions that were never entered also ignored every error
in a weakref callback run by the garbage collector on Python 3.14 (except the
free-threaded build), because its "on calling weakref callback" alternative had
no condition on the error. It now requires "Session was never entered" in all
cases.

Assisted-by: ClaudeCode:claude-opus-5-5

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant