MCPcopy Index your code
hub / github.com/python/cpython / set_trace

Function set_trace

Lib/pdb.py:2709–2724  ·  view source on GitHub ↗

Enter the debugger at the calling stack frame. This is useful to hard-code a breakpoint at a given point in a program, even if the code is not otherwise being debugged (e.g. when an assertion fails). If given, *header* is printed to the console just before debugging begins. *command

(*, header=None, commands=None)

Source from the content-addressed store, hash-verified

2707 return Pdb().runcall(*args, **kwds)
2708
2709def set_trace(*, header=None, commands=None):
2710 """Enter the debugger at the calling stack frame.
2711
2712 This is useful to hard-code a breakpoint at a given point in a
2713 program, even if the code is not otherwise being debugged (e.g. when
2714 an assertion fails). If given, *header* is printed to the console
2715 just before debugging begins. *commands* is an optional list of
2716 pdb commands to run when the debugger starts.
2717 """
2718 if Pdb._last_pdb_instance is not None:
2719 pdb = Pdb._last_pdb_instance
2720 else:
2721 pdb = Pdb(mode='inline', backend='monitoring', colorize=True)
2722 if header is not None:
2723 pdb.message(header)
2724 pdb.set_trace(sys._getframe().f_back, commands=commands)
2725
2726async def set_trace_async(*, header=None, commands=None):
2727 """Enter the debugger at the calling stack frame, but in async mode.

Callers

nothing calls this directly

Calls 3

messageMethod · 0.95
set_traceMethod · 0.95
PdbClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…