Reputation: 4460
# process_with_huge_time_overhead()
list_a = [1,2,3]
print(list_a[3])
# process_with_huge_time_overhead()
new_data = [5,6,7]
list_a += new_data
After reaching this line in ipdb (invoked via python -m ipdb script.py
), the exception is thrown: IndexError
How can one continue to debug and jump around without going through the overhead of getting to this point again?
If I jump to line 62 and use the n
command to execute the next line, it doesn't work. every n
just continues to exit the program.
Upvotes: 6
Views: 2229
Reputation: 3632
You can do something like this
try:
list_a = [1,2,3]
except Exception:
pass
print(list_a[3])
# process_with_huge_time_overhead()
new_data = [5,6,7]
list_a += new_data
Why we cannot skip using pdb.
Yes we can by changing the stack frame data
pdb inspects arbitrary Python code in the context of any stack frame.so one way to skip that is change the stack frame data (indirectly you will change the whole logic) .Best is to handle the code exception
Since you are using pycharm you can set the value or in pdb you change the value.But thats not recommended (as that changes the logic)
Upvotes: 1
Reputation: 2655
You cannot do this without changing the program.
The debugger follows the code execution. If an error is thrown, the debugger will continue following the programs flow of error handling. If the error is not handled by you, a crash is issued. This is expected behavior and the debugger will follow it.
Upvotes: 3