v0.0.345: sys.settrace / sys.setprofile (F7)#266
Merged
Conversation
Closes group F7 from notes/Spec/1500/1530_goipy_v01_gap_audit.md. Spec at notes/Spec/1500/1539_goipy_v0045_settrace_setprofile.md. - Interp.traceFn / profileFn / inTrace re-entry guard. - runFrame fires call/return/exception; result of global trace's 'call' becomes the per-frame LocalTrace. - Frame.LocalTrace + LastLine; LastLine seeded to FirstLineNo so the RESUME-on-def-line opcode does not fire a stray line event before the first body line. - Dispatch hot-loop guard: nil LocalTrace = near-zero overhead. Local trace returning None disables further line events; a callable replaces the local trace per CPython. - callFunctionFast frame-pool reset clears LocalTrace + LastLine. - Frame f_trace getter/setter wired via LocalTrace. - sys.settrace / gettrace / setprofile / getprofile. - Fixture 345_settrace_setprofile.py — round-trip, event sequence for f(), per-frame replacement, profile (no line events), disable mid-execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes group F7 from the v0.1.0 audit (
notes/Spec/1500/1530_goipy_v01_gap_audit.md). Spec atnotes/Spec/1500/1539_goipy_v0045_settrace_setprofile.md.pdb,coverage.py, and third-party profilers (yappi,line_profiler) drive their hooks throughsys.settrace/sys.setprofile. Goipy had stub no-ops inthreadingandpdband nothing onsysitself; tracers silently never fired.Interp.traceFn/profileFnplus aninTracere-entry guard so the tracer's own dispatch doesn't recurse.runFramefires'call'/'return'/'exception'events; the global trace's'call'return value becomes the per-frameLocalTrace.Frame.LocalTraceandFrame.LastLine;LastLineis seeded toCode.FirstLineNoon frame entry so the RESUME-on-def-line opcode does not fire a stray line event before the first body line — matching CPython 3.11+.LocalTraceis the common path → near-zero overhead. A local trace returningNonedisables further line events on that frame; a callable replaces the local trace.callFunctionFastframe-pool reset clearsLocalTrace+LastLine.Framef_tracegetter/setter wired viaLocalTrace.sys.settrace/gettrace/setprofile/getprofile.345_settrace_setprofile.py—gettraceround-trip, event sequence forf(), per-frame replacement, profile (no line events), disabling mid-execution.Test plan
go test ./... -timeout 600s— greenOut of scope
'opcode'event (f_trace_opcodesstays a no-op).sys.monitoring(PEP 669) — separate audit entry.frame.f_lineno = Njump during pdb.