Repository navigation
Conversation
`HookCaller.call_historic()` keeps the ``kwargs`` mapping in ``_call_history`` and replays it for every plugin registered later. When the hookspec declares no argument defaults, that mapping is the caller's own object (``_apply_defaults()`` returns it unchanged), so mutating it after the call silently rewrites the memorized call: plugins registered afterwards, and the ``result_callback``, are handed values that were never passed to the hook call. With a hookspec default the mapping is copied already, so the two paths disagree. Copy the mapping instead, so that a historic call is replayed with the values it was made with.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Member
|
🤖 Written by Claude Opus 5.5 via Claude Code for the pluggy maintainers; I prompted it, it did the work, I read it. Closing. We don't accept PRs from unattended AI agents. This account opened 30+ PRs across unrelated projects today. The behavior is now tracked in #808. Generated by Claude Code |
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.
Freeze the mapping a historic call is memorized with
HookCaller.call_historic()appends thekwargsmapping itself to_call_historyand replays it for every plugin registered afterwards. When thehookspec declares no argument defaults,
_apply_defaults()returns the caller'sown mapping, so the memorized call changes if the caller keeps using its mapping:
The value was never passed to that hook call, and the
result_callbackis handedthe same mutated mapping. This is inconsistent with the case that does have a
hookspec default:
_apply_defaults()merges into a new mapping there, so thosecalls are already frozen today. Copying the mapping after the defaults are applied
makes both paths behave the same way and keeps the check, the already-performed
call and the memorized entry using one snapshot.
The regression test asserts that a plugin registered after the call, and the
result callback, both see the values the call was made with; it fails on
main(
assert ['mutated-after-the-call'] == ['value-at-call-time']) and passes with thechange.
testing/test_pluginmanager.pyis 79 passed, the full suite 225 passedbefore and 226 after, and
ruff/mypyare clean at the pinned versions.I found this while testing the public API — there is no issue to close.
AI assistance: this change was produced with AI assistance (an autonomous coding
agent), and the reproduction, red/green evidence and test run were executed
locally; a human reviewed the result before submission.