This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Need command to exit PDB interactive shell
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Kerrick Staley, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-06-24 02:04 by Kerrick Staley, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg372226 - (view) Author: Kerrick Staley (Kerrick Staley) Date: 2020-06-24 02:04
In PDB, when you use "interact" to enter an interactive shell, the only way to exit that shell is to send an end-of-transmission (Ctrl+D) character. In some environments, such as Jupyter, this is awkward to do. Here is a StackOverflow post where a user encountered this issue:
https://stackoverflow.com/questions/47522316/exit-pdb-interactive-mode-from-jupyter-notebook/62546186

I think that the user should be able to type quit() in order to exit the interactive Python shell and go back to the PDB shell, similar to a regular interactive Python session. I think you should also support exit() because the Python shell supports that one as well (quit() and exit() do the same thing, I think the alias exists to help discoverability for new users).

I confirmed this issue on Python 3.6.9 and 3.8.3.
msg372233 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-24 06:04
Both "exit" and "quit" and even just "q" quit the PDB interactive shell.
msg372270 - (view) Author: Kerrick Staley (Kerrick Staley) Date: 2020-06-24 17:23
Serhiy: I'm referring to the interactive mode that can be entered by typing "interact" in PDB.

Here are reproduction instructions:
1. Run "python3" command.
2. In Python shell, type "import pdb; pdb.set_trace()".
3. In PDB shell, type "interact".

Now, in this "PDB InteractiveConsole" shell (I'm not sure what it's called), the only way to go back to PDB is to press Ctrl+D. If you type "quit()" or "exit()" it exits the entire Python process. If you type "q" it says "NameError: name 'q' is not defined".

In Jupyter, I get different (but still undesirable) behavior: "quit()" raises "NameError: name 'quit' is not defined" (and similar for "exit()").

I think "quit()"/"exit()" in these contexts should return you back to the PDB shell.
msg372274 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-24 19:27
Thank you, now I understand the problem.

It is reasonable request, but a new feature can only be added in Python 3.10.
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85268
2020-06-24 19:27:11serhiy.storchakasetmessages: + msg372274
versions: + Python 3.10, - Python 3.6, Python 3.7, Python 3.8
2020-06-24 17:23:50Kerrick Staleysetmessages: + msg372270
2020-06-24 06:04:13serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg372233
2020-06-24 02:04:35Kerrick Staleycreate