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

Only support restart command in pdb when it's a command line usage #123756

Closed
gaogaotiantian opened this issue Sep 6, 2024 · 5 comments
Closed
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@gaogaotiantian
Copy link
Member

gaogaotiantian commented Sep 6, 2024

Feature or enhancement

Proposal:

Now when we have a breakpoint() in the source code and enter pdb, we can do restart and raise a Restart exception - which in most cases will just stop the program with an exception. For other rare cases, it might be even worse.

It simply does not make sense to allow a restart command if pdb is not brought up from command line - that exception is only caught in command line usage. So, we should only allow restart in command line usage and do nothing (except for an error) in other cases.

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

@iritkatriel
Copy link
Member

Rather than allow_restart, I'd add an enum for the ways that pdb can be invoked. That could be useful for other things.

@picnixz picnixz added the stdlib Python modules in the Lib dir label Sep 6, 2024
@gaogaotiantian
Copy link
Member Author

Do you mean an indicator for whether pdb is invoked through a inline breakpoint or command line?

@iritkatriel
Copy link
Member

Do you mean an indicator for whether pdb is invoked through a inline breakpoint or command line?

Yes

@gaogaotiantian
Copy link
Member Author

In that case, do you think we should have an unknown option as the default - just to keep all the old behavior? Or we should be a bit more aggressive, and use inline(or some other word) as default, to keep the default behavior safer for users? In another word, only allow commands like restart when the pdb is invoked with an explicit option.

Besides restart, I'll also work on exit later. Currently when the user exits pdb invoked by an inline breakpoint an error will be raised and it's just weird to show a trackback of an exception when I exit the debugger. I'll make the behavior similar to other debuggers - ask the user whether they want to exit the process, and do a os._exit() to kill everything quietly.

@iritkatriel
Copy link
Member

It can be None by default, and for each situation make None behave like it used to.

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

No branches or pull requests

3 participants