~/talk

Trace functions: Building a tiny debugger

Talkat PyCon Italia 2023 · 2023-05-25..05-28· [python]
slides:none on file

Shows how to use sys.settrace and a returned local tracer to build a tiny pdb replacement that actually works: captures events call, line, return and exception, reads source with inspect to print context, evaluates expressions with frame.f_globals/frame.f_locals, and uses sys.getframe to place the breakpoint at the caller. Implements commands: quit, continue, step/step‑into, jump‑to‑return and list with numbered context; demo proves the debugger runs and the main limitation is needing a small getframe hack to trace the exact breakpoint location.

AI-written summary · about

  1. 0:00Introduction and setup
  2. 1:00Debugging basics with pdb
  3. 2:22Understanding trace functions
  4. 4:22Inspecting code execution
  5. 8:35Building an interactive REPL
  6. 10:34Adding evaluation and control
  7. 12:50Implementing stepping
  8. 15:25Advanced debugger features
  9. 19:37Conclusion and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.