Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#808 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@RonnyPfannschmidt đang làm issue này rồi.

Từ ngày 21/10/2026.

  • #810 của @rajnish-verma-22172 — đã đóng, không merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

🤖 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.

Ngôn ngữ chính
Python
Star
1.7k
Fork
192
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
25

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pluggy

Tất cả issue của pytest-dev/pluggy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.