This is post-mortem mode of pdb/ipdb. Commands like jump
, next
, step
, return
are not available because the script is no longer running.
The post-mortem mode is for intercepting unhandled exceptions and inspecting the program state whenever such exception is raised, without having to sprinkle the code with pdb.set_trace()
(or simply breakpoint()
since python 3.7).Can be easily provoked by something like print(a)
without defining a
or the classical division by zero 1/0
.
The continue
command, shorthand c
, is kind-of available in the post-mortem mode but what it really does in such mode is it causes pdb/ipdb to finish the post-mortem, reload the file, and restart the script with any breakpoints, shorthand b
, e.g. b 20
for line 20, you might have prepared during the post-mortem.
See also this answer to a similar question.
As Steven Kryscala on codementor says:
When pdb says it will restart the program, or when you use the restart command, code changes to the script you're debugging will be reloaded automatically. Breakpoints will still be set after reloading, but may need to be cleared and re-set due to line numbers shifting. Code changes to other imported modules will not be reloaded — you will need to quit and re-run the -mpdb command to pick those up.