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

Change in pdb behavior at exit from post-mortem debugger #118714

Closed
chgnrdv opened this issue May 7, 2024 · 3 comments
Closed

Change in pdb behavior at exit from post-mortem debugger #118714

chgnrdv opened this issue May 7, 2024 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@chgnrdv
Copy link
Contributor

chgnrdv commented May 7, 2024

Bug report

Bug description:

In 3.12 and earlier, if user enters quit/exit commands or does Ctrl-D, pdb restarts script with corresponding message and exits only on repeated quit/exit/Ctrl-D:

$ python -m pdb -c c pdb_bug.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/pdb.py", line 1775, in main
    pdb._run(target)
  File "/usr/local/lib/python3.11/pdb.py", line 1643, in _run
    self.run(target.code)
  File "/usr/local/lib/python3.11/bdb.py", line 600, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/radislav/projects/cpython/pdb_bug.py", line 1, in <module>
    raise ValueError()
ValueError
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/radislav/projects/cpython/pdb_bug.py(1)<module>()
-> raise ValueError()
(Pdb) quit
Post mortem debugger finished. The /home/radislav/projects/cpython/pdb_bug.py will be restarted
> /home/radislav/projects/cpython/pdb_bug.py(1)<module>()
-> raise ValueError()
(Pdb) quit
$

Since fa18b0a only message is printed, but Python exits completely:

$ ./python -m pdb -c c pdb_bug.py 
Traceback (most recent call last):
  ...
  File "/home/radislav/projects/cpython/pdb_bug.py", line 1, in <module>
    raise ValueError()
ValueError
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/radislav/projects/cpython/pdb_bug.py(1)<module>()
-> raise ValueError()
(Pdb) quit
Post mortem debugger finished. The /home/radislav/projects/cpython/pdb_bug.py will be restarted
$

@gaogaotiantian, what's your opinion? Should we restore the old behavior or remove confusing message about "restart"? As I can see, pdb docs doesn't state explicitly what quit/exit commands should do in post-mortem debugger.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@chgnrdv chgnrdv added the type-bug An unexpected behavior, bug, or error label May 7, 2024
@gaogaotiantian
Copy link
Member

I think we should make quit quit and restart restart. It's inconsistent for the post-mortem debugger to have a different behavior. We noticed the user that cont and step will restart the program, which is fine and has been the case for a really long time, but quit should not just quit the post mortem debugger and enter the normal debugger, they should explicitly ask a restart.

So we need to do something about the message - I'll work on that. This is a bug fix so it doesn't have to be merged before beta freeze.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 3, 2024
…reasonable (pythonGH-118725)

(cherry picked from commit e245ed7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
gaogaotiantian added a commit that referenced this issue Jul 3, 2024
… reasonable (GH-118725) (#121346)

gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (GH-118725)
(cherry picked from commit e245ed7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
@ambv
Copy link
Contributor

ambv commented Jul 14, 2024

Should this still be open?

@gaogaotiantian
Copy link
Member

Fixed in #118725

estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants