Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

call_historic() memorizes the caller's kwargs mapping, so later mutation changes what late plugins receive

未关闭
#808 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@RonnyPfannschmidt 已经在做这个了。

开始于 2026年10月21日。

  • #810 来自 @rajnish-verma-22172 —— 已关闭,未合并

评估

这个 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pytest-dev/pluggy 的其他 Issue

查看 pytest-dev/pluggy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。