You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hook tracing crashes with specced Mock arguments and results #792
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.
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.
/take — reproduced on main 21c7e16: with tracing enabled, a specced Mock (spec=str / spec=dict) passed as a hook arg (or first result) raises TypeError from the tracing path before/instead of the implementation running. Planning a minimal fix in the hook-tracing formatting so spec'd mocks aren't routed through the str/dict special-casing.
Activity
document the tracing fix for specced mocks
DawnofGenX commentedon Oct 15, 2026
/take — reproduced on main 21c7e16: with tracing enabled, a specced Mock (spec=str / spec=dict) passed as a hook arg (or first result) raises TypeError from the tracing path before/instead of the implementation running. Planning a minimal fix in the hook-tracing formatting so spec'd mocks aren't routed through the str/dict special-casing.
Sandeep1519-droid commentedon Oct 16, 2026
Thanks for reproducing this, @DawnofGenX! There’s a proposed fix with regression tests in #793. Any feedback would be welcome.