-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Disallow abbreviated command-line options #5469
Merged
Merged
Conversation
This file contains 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
Closing and reopening, in hopes of getting codecov unstuck: |
nicoddemus
reviewed
Jun 24, 2019
Codecov Report
@@ Coverage Diff @@
## features #5469 +/- ##
============================================
- Coverage 94.48% 93.84% -0.64%
============================================
Files 114 114
Lines 25528 25528
Branches 2482 2482
============================================
- Hits 24119 23957 -162
- Misses 1095 1251 +156
- Partials 314 320 +6
Continue to review full report at Codecov.
|
nicoddemus
reviewed
Jun 25, 2019
nicoddemus
approved these changes
Jun 25, 2019
Great work! 👍 |
This was referenced Jun 25, 2019
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 14, 2019
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytestGH-5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967 (cherry picked from commit dffca9e) Co-authored-by: Zac Hatfield-Dodds <Zac-HD@users.noreply.github.com>
miss-islington
pushed a commit
to python/cpython
that referenced
this pull request
Jul 14, 2019
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
encukou
pushed a commit
to python/cpython
that referenced
this pull request
Jul 14, 2019
…4759) The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytestGH-5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967 (cherry picked from commit dffca9e) Co-authored-by: Zac Hatfield-Dodds <Zac-HD@users.noreply.github.com>
lisroach
pushed a commit
to lisroach/cpython
that referenced
this pull request
Sep 10, 2019
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
DinoV
pushed a commit
to DinoV/cpython
that referenced
this pull request
Jan 14, 2020
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
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.
This was previously allowed where the ArgumentParser thought it was unambiguous, because this could be incorrect due to delayed parsing of options for plugins.
Fixes #1149, fixes #3413, and fixes #4009 - it's been a known problem for quite a while, but this fix is only available on Python 3.5+... which means we can finally do it! Replaces #5467, in that it also defines
MyOptionParser._parse_optional
, in order to work around an upstream bug that disables combining short options, such as-vv
.We should avoid merging this until python/cpython#14316 is merged and we know that we don't need to do our conditional backport on 3.8.