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

gh-84583: Make pdb enter post-mortem mode even for SyntaxError #110883

Merged
merged 2 commits into from Oct 15, 2023

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Oct 14, 2023

In #60384, a special check for SyntaxError is introduced in pdb's main() function to avoid infinite loop in pdb if the source file has a SyntaxError. The solution is not elegant enough as we could have a real SyntaxError which we want to debug at run-time. #84583 gave an example with ast.literal_eval(''). This could happen in other scenarios as well, when we compile dynamically generated code.

The original check for SyntaxError was just to prevent pdb from stuck, we can easily do that by moving the pdb._user_requested_quit outside of the try statement, so the quit request from post-mortem mode can be respected too.

This has one minor behavior change - when the user tries to "exit" from the post mortem debugging, for example, using Ctrl+D or quit command, pdb used to restart the program, now it will exit.

I think this is a more reasonable behavior - we told the users explicitly to use cont and step to restart the program, and exit should just mean "exit".

@iritkatriel iritkatriel added the type-feature A feature request or enhancement label Oct 15, 2023
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@iritkatriel iritkatriel merged commit fa18b0a into python:main Oct 15, 2023
27 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-syntax-error branch October 15, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants