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)
| 2707 | return Pdb().runcall(*args, **kwds) |
| 2708 | |
| 2709 | def 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 | |
| 2726 | async def set_trace_async(*, header=None, commands=None): |
| 2727 | """Enter the debugger at the calling stack frame, but in async mode. |