Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-108791: Fixpdb
CLI invalid argument handling#108816
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
`pdb` module, if invoked with invalid command line arguments, produces large traceback and/or tries to run debugger on errorneus target, such as directory. This patch improves error handling in pdb CLI, making error messages more concise.
chgnrdv commentedSep 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I had to make changes in
|
…on into pdb-cli-fix-error-handling
Lib/pdb.py Outdated
except Exception: | ||
traceback.print_exc() | ||
except Exception as e: | ||
print(f"{type(e).__name__}: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you make it something like
try:self._detailsexcept ... :# Something you expectprint(f"{type(e).__name__}:{e}")exceptException:traceback.print_exc()
to leave the general case untouched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looking at therunpy._get_module_details
source,ImportError
seems to be the only type of exception that can be raised here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think the improvement is fine. The argument parser piece is a bit hacky, but I'm planning to convert that part to argparse anyway (getopt
has not been updated for like 10 years) so it's okay.
Hi@chgnrdv , as I updated pdb to use |
@gaogaotiantian, thanks for notice, I'll take a look tomorrow. |
LGTM,@iritkatriel could you take a look? Thanks! |
Uh oh!
There was an error while loading.Please reload this page.
LGTM. Should this be backported? |
Rare case, but safe and backward compatible. I think it should be back-ported. |
Agreed |
Thanks@chgnrdv for the PR, and@iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-110915 is a backport of this pull request to the3.12 branch. |
GH-110916 is a backport of this pull request to the3.11 branch. |
GH-111063 is a backport of this pull request to the3.11 branch. |
GH-111064 is a backport of this pull request to the3.12 branch. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#108791.
pdb
module, if invoked with invalid command line arguments, produces large traceback and/or tries to run debugger on errorneus target, such as directory. This patch improves error handling in pdb CLI, making error messages more concise.pdb
CLI doesn't handle incorrect arguments properly #108791