Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#808 コメント 2 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
25

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytest-dev/pluggy のほかの issue

pytest-dev/pluggy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。