Skip to content

Do not raise an Exception when exiting pdb #124703

@gaogaotiantian

Description

@gaogaotiantian

Feature or enhancement

Proposal:

Currently, if you set a breakpoint() in your code, and exit with q or ctrl+D, the output is just ugly:

Traceback (most recent call last):
  File "/Users/gaotian/programs/cpython/example.py", line 11, in <module>
    while True:
          ^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/bdb.py", line 90, in trace_dispatch
    return self.dispatch_line(frame)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/bdb.py", line 115, in dispatch_line
    if self.quitting: raise BdbQuit
                      ^^^^^^^^^^^^^
bdb.BdbQuit

It makes no sense to print a trackback of an exception just because I want to quit pdb and stop debugging. Now that we have an indicator for inline mode, we can deal with this.

What I propose is - for inline mode debugging, any quit attempt(q, ctrl+D, etc.) will trigger a confirm prompt (like gdb or lldb), the user can say no and go back to debugging, or they can confirm and quit the program.

There are a few design details which I will list in the following PR.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions