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-123756: Only allow restart in command line mode #123757

Merged
merged 19 commits into from
Sep 25, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Sep 6, 2024

An allow_restart argument is added to pdb.Pdb to enable run/restart command when needed (for stdlib, only in command line mode).

@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , could you take a quick look at the proposal and the implementation and see if this makes sense? I will add the tests and the documentation after your pre-approval.

@gaogaotiantian
Copy link
Member Author

Okay I defined a new Enum - PdbInvokeType for pdb to check whether to enable some commands internally. I also exported the enum because the debuggers based on pdb might need it.

Do you think code wise this is the way to go? I'll work on the docs and tests if the feature is good to go.

Lib/pdb.py Outdated Show resolved Hide resolved
Lib/pdb.py Outdated Show resolved Hide resolved
@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , I updated the docs and tests, also renamed the enum class. Could you review it? Thanks!

Doc/library/pdb.rst Outdated Show resolved Hide resolved
Doc/library/pdb.rst Outdated Show resolved Hide resolved
Doc/library/pdb.rst Outdated Show resolved Hide resolved
@gaogaotiantian
Copy link
Member Author

Hey @iritkatriel , I made some changes after the discussion on discord. Now the name of the argument is mode and it accepts a string 'cli' or 'inline', or a None.

A few questions - do you think we should add run-time checker for the value? If we do, will it affect devs that build their debugger based on pdb? Should we have a separate method to check it so it can be overwritten? We can also do a setting kind of thing.

The related question - should we type hint this? It's not common to type hint arguments in pdb.py - one of the reasons is of course the age of the file. However, last time I heard there's still a debate on whether we should type hint as much as possible in stdlibs.

I think one thing we need to factor in is that - this argument is basically exclusively used by debugger developers. The debugger users should never need to use this. So maybe we can cut some corners (not making it super safe to use).

For the documentation, for restart command, I did not link the availability of the command to the mode argument directly because that's not how normal user experiences the difference.

Doc/library/pdb.rst Outdated Show resolved Hide resolved
Doc/library/pdb.rst Outdated Show resolved Hide resolved
Lib/pdb.py Outdated Show resolved Hide resolved
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Lib/pdb.py Outdated Show resolved Hide resolved
Lib/pdb.py Outdated Show resolved Hide resolved
gaogaotiantian and others added 2 commits September 24, 2024 21:47
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Doc/library/pdb.rst Outdated Show resolved Hide resolved
Doc/library/pdb.rst Outdated Show resolved Hide resolved
Doc/library/pdb.rst Outdated Show resolved Hide resolved
Lib/pdb.py Outdated Show resolved Hide resolved
gaogaotiantian and others added 3 commits September 25, 2024 09:58
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@gaogaotiantian
Copy link
Member Author

The doc change makes sense. I also added the whatsnew entry.

@gaogaotiantian gaogaotiantian merged commit 28efeef into python:main Sep 25, 2024
36 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-allow-restart branch September 25, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants