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

[3.8] bpo-26967: fix flag grouping with allow_abbrev=False (GH-14316) #14759

Merged
merged 1 commit into from Jul 14, 2019

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented 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

https://bugs.python.org/issue26967

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
Copy link
Contributor Author

@Zac-HD: Status check is done, and it's a success ✅ .

@encukou encukou merged commit b1e4d1b into python:3.8 Jul 14, 2019
@miss-islington miss-islington deleted the backport-dffca9e-3.8 branch July 14, 2019 06:00
@miss-islington
Copy link
Contributor Author

@Zac-HD: Status check is done, and it's a success ✅ .

1 similar comment
@miss-islington
Copy link
Contributor Author

@Zac-HD: Status check is done, and it's a success ✅ .

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.

None yet

5 participants