Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need command to exit PDB interactive shell #85268

Closed
KerrickStaley mannequin opened this issue Jun 24, 2020 · 5 comments
Closed

Need command to exit PDB interactive shell #85268

KerrickStaley mannequin opened this issue Jun 24, 2020 · 5 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@KerrickStaley
Copy link
Mannequin

KerrickStaley mannequin commented Jun 24, 2020

BPO 41096
Nosy @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-06-24.02:04:35.446>
labels = ['type-feature', 'library', '3.10']
title = 'Need command to exit PDB interactive shell'
updated_at = <Date 2020-06-24.19:27:11.039>
user = 'https://bugs.python.org/KerrickStaley'

bugs.python.org fields:

activity = <Date 2020-06-24.19:27:11.039>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-06-24.02:04:35.446>
creator = 'Kerrick Staley'
dependencies = []
files = []
hgrepos = []
issue_num = 41096
keywords = []
message_count = 4.0
messages = ['372226', '372233', '372270', '372274']
nosy_count = 2.0
nosy_names = ['serhiy.storchaka', 'Kerrick Staley']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue41096'
versions = ['Python 3.10']

@KerrickStaley
Copy link
Mannequin Author

KerrickStaley mannequin commented Jun 24, 2020

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.

@KerrickStaley KerrickStaley mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 24, 2020
@serhiy-storchaka
Copy link
Member

Both "exit" and "quit" and even just "q" quit the PDB interactive shell.

@KerrickStaley
Copy link
Mannequin Author

KerrickStaley mannequin commented Jun 24, 2020

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.

@serhiy-storchaka
Copy link
Member

Thank you, now I understand the problem.

It is reasonable request, but a new feature can only be added in Python 3.10.

@gaogaotiantian
Copy link
Member

exit() and quit() exits the interactive context and return to PDB console now with #102896 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants