ipdb: quit does not abort

I hope I’m not the only one with this problem, but since I’ve upgraded to IPython 5, it is impossible to quit from a ipdb session, as before.

Here is a sample script:

def main():
    print('hello')
    while True:
        import ipdb; ipdb.set_trace()
        print('loop')

if __name__ == '__main__':
    main()

And a sample run:

python3 mwe.py
hello
> /home/dojeda/temp/mwe.py(5)main()
      3     while True:
      4         import ipdb; ipdb.set_trace()
----> 5         print('loop')
      6 
      7 if __name__ == '__main__':

ipdb> c
loop
> /home/dojeda/temp/mwe.py(4)main()
      2     print('hello')
      3     while True:
----> 4         import ipdb; ipdb.set_trace()
      5         print('loop')
      6 

ipdb> q
loop
> /home/dojeda/temp/mwe.py(5)main()
      3     while True:
      4         import ipdb; ipdb.set_trace()
----> 5         print('loop')
      6 
      7 if __name__ == '__main__':

ipdb> quit()
loop
> /home/dojeda/temp/mwe.py(4)main()
      2     print('hello')
      3     while True:
----> 4         import ipdb; ipdb.set_trace()
      5         print('loop')
      6 

ipdb> !!q
loop
> /home/dojeda/temp/mwe.py(5)main()
      3     while True:
      4         import ipdb; ipdb.set_trace()
----> 5         print('loop')
      6 
      7 if __name__ == '__main__':

ipdb> import sys; sys.exit(0)
*** SystemExit: 0
ipdb>

Version information: ipdb==0.10.1 ipython==5.1.0

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 35
  • Comments: 19 (1 by maintainers)

Most upvoted comments

Use import os; os._exit() as a workaround

Add to ~/.pdbrc :

import os
alias kk os._exit(0)

then hit kk from inside an ipdb session, to exit.

(this is just a convenient workaround, the issue still needs to be fixed!)

How can we elevate the priority of this issue, or at least get it assigned to someone? It’s a complete show-stopper and is hurting ipdb uptake.

I believe you can close this issue as https://github.com/ipython/ipython/pull/10009 fixed the bug. I just upgraded from 5.1 to 5.3 and it is all good.

After some more investigation, it turns out that this is actually an IPython issue. A fix is in the make for IPython 5.2. https://github.com/ipython/ipython/issues/10006

Downgrade to ipython==5.0.0

Hello, I have the exact ssame issue.When I run python2 code, i cannot exit the debugger.

def main():
    print 'hello'
    while True:
        import ipdb; ipdb.set_trace()
        print('loop')

if __name__ == '__main__':
    main()

This outputs me when i try to exit:

Post mortem debugger finished. The tmp.py will be restarted
Traceback (most recent call last):
  File "/home/operman/anaconda3/lib/python3.5/site-packages/ipdb/__main__.py", line 198, in main
    pdb._runscript(mainpyfile)
  File "/home/operman/anaconda3/lib/python3.5/pdb.py", line 1542, in _runscript
    self.run(statement)
  File "/home/operman/anaconda3/lib/python3.5/bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/operman/bAbYCIM/networkGraph/tmp.py", line 2
    print 'hello'
                ^
SyntaxError: Missing parentheses in call to 'print'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> <string>(1)<module>()

Hi, Is there any news about this issue?

@ssbarnea I am happy that you nicely offer to make it happen. PR welcome.