gh-66436: Improved prog default value for argparse.ArgumentParser#124799
Merged
serhiy-storchaka merged 10 commits intopython:mainfrom Oct 1, 2024
Merged
gh-66436: Improved prog default value for argparse.ArgumentParser#124799serhiy-storchaka merged 10 commits intopython:mainfrom
serhiy-storchaka merged 10 commits intopython:mainfrom
Conversation
It can now have one of three forms: * basename(argv0) -- for simple scripts * python arv0 -- for directories, ZIP files, etc * python -m module -- for imported modules
5ba9a91 to
1977630
Compare
Lib/argparse.py
Outdated
Comment on lines
1708
to
1709
| if (modspec.name == '__main__' and not modspec.parent and modspec.has_location | ||
| and _os.path.dirname(modspec.origin) == _os.path.join(_os.getcwd(), arg0)): |
Member
Author
There was a problem hiding this comment.
Actually, it seems that this condition can be simplified to simply modspec.name == '__main__'. What are your thoughts @ncoghlan?
Member
Author
There was a problem hiding this comment.
Actually, additionally checks were just an obstacle, because of differences in normalization between Unix and Windows. So I removed them.
ncoghlan
approved these changes
Oct 1, 2024
Contributor
ncoghlan
left a comment
There was a problem hiding this comment.
LGTM! Assorted minor comments inline, either tweaking docs wording, or else making the code handle obscure edge cases more gracefully.
Misc/NEWS.d/next/Library/2024-09-30-19-59-28.gh-issue-66436.4gYN_n.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
serhiy-storchaka
commented
Oct 1, 2024
Member
Author
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you for your suggestions @ncoghlan. I applied them all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It can now have one of three forms:
📚 Documentation preview 📚: https://cpython-previews--124799.org.readthedocs.build/