如何在事后调试中退出ipdb? [英] How to quit ipdb while in post-mortem debugging?
问题描述
我喜欢使用以下方法检查Python脚本中的错误:
I like to inspect error in a Python script by using:
$ python3 -m pdb my_script.py
这让我进入了一个pdb提示符,我可以从那里 c
继续执行,当它遇到错误时,我可以检查变量,然后 q
退出脚本执行以返回我的shell。
This drops me into a pdb prompt from where I can c
continue the execution, and when it hits error, I can inspect the variables and then q
quit the script execution to get back to my shell.
我尝试使用iPython调试器模块,因为它更加丰富多彩:
I tried the same with iPython debugger module, since it is more colorful:
$ python3 -m ipdb my_script.py
但是,一旦检查完毕,我就无法退出调试器错误。使用 q
quit命令只需在重新执行脚本和事后模式之间切换:
However, I am not able to quit the debugger once I am done inspecting the error. Using the q
quit command just keeps switching it between re-executing the script and post-mortem mode:
$ python3 -m ipdb my_script.py
ipdb> c
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> Inspect some variables at this point
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
如何退出这个调试器?
推荐答案
这是IPython 5.1中的一个错误。它已在此拉取请求中修复,不再是IPython 5.2及更高版本的问题。您现在可以使用 q
, quit()
或 Ctrl + d 退出调试器。
This was a bug in IPython 5.1. It was fixed in this pull request and is no longer an issue from IPython 5.2 and onwards. You can now use q
, quit()
, or Ctrl+d to exit the debugger.
这篇关于如何在事后调试中退出ipdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!