Repository navigation
Require pluggy>=1.6 so caplog keeps its handler (#9236) - #15128
Merged
RonnyPfannschmidt merged 1 commit intoOct 17, 2026
Merged
Conversation
RonnyPfannschmidt
force-pushed
the
fix-9236-pluggy-floor
branch
from
October 11, 2026 07:26
2e93356 to
c64a6a6
Compare
pluggy < 1.6 stopped running the remaining hook wrapper teardowns once an old-style hookwrapper raised in its own teardown. The logging plugin's pytest_runtest_call wrapper stayed suspended inside catching_logs, held by a reference cycle through the exception traceback. When gc finalised it, the stale catching_logs.__exit__ removed the plugin's shared LogCaptureHandler from the root logger -- the same handler the next test's caplog had just attached -- so that test recorded nothing. pytest-dev/pluggy#546 (released in 1.6.0) runs every teardown, so the wrapper always unwinds in place. The regression test runs in a subprocess: in-process, the HookRecorder keeps the failing call's CallInfo alive, the wrapper is never finalised, and the test passes on pluggy 1.5 as well. Closes pytest-dev#9236 Co-Authored-By: Claude Opus 5.5 via Claude Code <noreply@anthropic.com>
RonnyPfannschmidt
force-pushed
the
fix-9236-pluggy-floor
branch
from
October 14, 2026 20:28
c64a6a6 to
20d5e7d
Compare
nicoddemus
approved these changes
Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.
Closes #9236.
#9236 is not a garbage-collected handler, and #11123 did not fix it. It is a pluggy bug that pluggy 1.6.0 fixed (pytest-dev/pluggy#546), and it is still reachable because pytest allows
pluggy>=1.5.Mechanism
_multicallwhen an old-stylehookwrapperraises in its own teardown. Every remaining teardown is skipped.pytest_runtest_callwrapper is one of them. It stays suspended inside_runtest_for, still holding its enteredcatching_logscontexts, kept alive by a cycle through the exception traceback.catching_logs.__exit__removescaplog_handlerfrom the root logger. There is one handler per plugin, so that is the same object the next test'scaplogjust attached, and that test records nothing.The reproducer from the issue still fails on current main with pluggy 1.5.0 and passes with 1.6.0. Bisecting pluggy points to pytest-dev/pluggy#546.
Change
pluggy>=1.6,<2inpyproject.tomlanduv.lock. pluggy 1.6 needs Python >= 3.9, so there is no conflict with our >= 3.10.testing/logging/test_fixture.py. It fails on pluggy 1.5.0 and passes on 1.6.0. It runs in a subprocess because in-process theHookRecorderkeeps the failing call'sCallInfo, whose traceback keeps the suspended wrapper alive, so the bug never shows.