Hook tracing crashes with specced Mock arguments and results
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 17/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
The reproduction calls pm.enable_tracing() and pm.trace.root.setwriter(print) on a PluginManager, and the TypeError comes from tracing code that uses isinstance on arguments and results. Start by running the reproduction script and finding the tracing formatter or result handler it reaches. Done means a specced Mock for both str and dict is logged without changing the hook result. Pull request #793 already addresses this, so review it before starting new work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
On main at 21c7e1672941a0cd9e3c555bf5e5007f1fbe3dc5 (Python 3.12.13), enabling hook tracing changes a successful hook call into a TypeError when an argument or first-result return value is a specced unittest.mock.Mock.
from unittest.mock import Mock
import pluggy
hookspec = pluggy.HookspecMarker("example")
hookimpl = pluggy.HookimplMarker("example")
class Spec:
@hookspec(firstresult=True)
def echo(self, value):
"""Return the value."""
class Plugin:
@hookimpl
def echo(self, value):
return value
for spec in (str, dict):
pm = pluggy.PluginManager("example")
pm.add_hookspecs(Spec)
pm.register(Plugin())
value = Mock(spec=spec)
assert pm.hook.echo(value=value) is value
pm.trace.root.setwriter(print)
pm.enable_tracing()
try:
assert pm.hook.echo(value=value) is value
except TypeError as exc:
print(spec.__name__, exc)
The string mock raises TypeError: object of type 'Mock' has no len() before the implementation runs. The dictionary mock raises TypeError: 'Mock' object is not iterable while tracing the result.
Mock(spec=...) reports its spec through __class__, so isinstance routes these objects into string formatting or dictionary metadata handling even though they are mocks. Tracing should log the mock without changing the hook result.
This report and a tested proposed fix were prepared with Codex.
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 187
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 24
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytest-dev/pluggy
-
Plugin registry compares plugins by equality, not identityCó thể đã có người làm @00200200 đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
pytest-dev/pluggy#760 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
deprecate passing None as a plugin instanceCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
pytest-dev/pluggy#790 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Defaulted positional-only hook parameters are forwarded as keywordsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 45/100
pytest-dev/pluggy#774 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
unregister() argument validation relies on assertCó thể đã có người làm @ekanshul đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
pytest-dev/pluggy#762 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Failures during add_hookspecs / historic replay leave partial stateCó thể đã có người làm @starx710 đã nhận 3 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
pytest-dev/pluggy#761 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytest-dev/pluggy
Issue tương tự
-
bot-triaged module: LrScheduler module: optimizer triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation glm5 llm-model
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vllm-project/vllm-ascend#19062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Author Page: shuai-zhao-llmĐang mởauthor-page correction
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
acl-org/acl-anthology#10496 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Issue Type: Bug Report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
celery/celery#10875 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SasanLabs/VulnerableApp#836 ·
Maintainer thường phản hồi trong vòng 1 ngày