inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

pudb kills ipython session on exit #364

Closed jfmoulin closed 4 years ago

jfmoulin commented 5 years ago

When working under ipython (ver), if a script raises an error and I do a post mortem analysis it seems impossible to get back to my original ipython session. This is pretty annoying in case the script is debugged after a computing intensive preparation step in the interactive shell.

steps to reproduce:

under ipython 7.4.0: 

    - run a script that raises an exception
    - pudb.pm()
    - ! #to get a shell (ipython in my case)
    - hack hack...
    - ctrl D # to exit the shell and return to pudb
    - exit debugger or continue to next statement 
    -> does not return to initial ipython session but quits alltogether

It seems this happens only if I invoke an ipy shell from the pudb. If I simply inspect code and exit everything works fine and I get back to my original shell session.

asmeurer commented 5 years ago

I guess when you exit the inner shell, it causes IPython to completely shut down. IPython unfortunately only ever has a single shell instance globally.

Probably the simplest way to fix it would be to temporarily override exit() and Ctrl-D in the inner shell to just exit the shell without shutting it down.

asmeurer commented 5 years ago

Maybe we can catch SystemExit. I don't know if the cleanup happens before or after it is raised.

jfmoulin commented 5 years ago

Indeed, I had a look at IPy's doc and it states:

At present, embedding IPython cannot be done from inside IPython. Run the code samples below outside IPython.

so there are probably complications. Maybe I should raise the issue at IPython's page...