call_historic() memorizes the caller's kwargs mapping, so later mutation changes what late plugins receive
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
🤖 Written by Claude Opus 5.5 via Claude Code for the pluggy maintainers; I prompted it, it did the work, I read it.
HookCaller.call_historic() appends kwargs to _call_history and replays it for plugins registered later. When the hookspec has no argument defaults, _apply_defaults() returns the caller's own mapping unchanged, so the history holds a reference to the caller's object:
d = {"arg": "at-call-time"}
pm.hook.myhook.call_historic(kwargs=d)
d["arg"] = "mutated"
pm.register(LatePlugin()) # LatePlugin.myhook receives arg="mutated"
When the spec has defaults, _apply_defaults() builds a new dict, so those calls are already isolated. The behavior therefore depends on whether the spec happens to declare a default.
Fix: store dict(kwargs) after applying defaults. This is a shallow copy, so mutable argument values are still shared, and that's expected. Low priority: nobody has reported it in the wild, and pytest passes fresh dicts.
Found while reviewing #806.
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 192
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 25
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytest-dev/pluggy 的其他 Issue
-
Plugin registry compares plugins by equality, not identity可能已有人在做 @00200200 于 12 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
pytest-dev/pluggy#760 ·
维护者通常 1 天内回复
-
deprecate passing None as a plugin instance可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
pytest-dev/pluggy#790 · 1 条评论 ·
维护者通常 1 天内回复
-
Defaulted positional-only hook parameters are forwarded as keywords可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 1-2 天 新手友好度 45/100
pytest-dev/pluggy#774 · 3 条评论 ·
维护者通常 1 天内回复
-
unregister() argument validation relies on assert可能已有人在做 @ekanshul 于 13 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 42/100
pytest-dev/pluggy#762 ·
维护者通常 1 天内回复
-
Failures during add_hookspecs / historic replay leave partial state可能已有人在做 @starx710 于 9 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 50/100
pytest-dev/pluggy#761 ·
维护者通常 1 天内回复
查看 pytest-dev/pluggy 的全部 Issue
相似的 Issue
-
Python Volcengine provider returns failures instead of raising them可能已有人在做 @Ricardo-M-L 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval fails可能已有人在做 @HuaTNA 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
test(bm_generation): pin the learning parameters and CPU sync shortcut可能已有人在做 @iloveeyjafjalla 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
elder-plinius/V3R1T4S#625 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复