Skip to content

argparse: abbreviated single-dash long options do not work with = #124345

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

Closed
serhiy-storchaka opened this issue Sep 23, 2024 · 0 comments
Closed
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Sep 23, 2024

argparse supports short options, single-dash long options and double-dash long options. Values for option can be specified as separate argument (for all types of options):

--option value
-option value
-o value

It can also be grouped in a single argument with the option. In this case it should be separated by = from the option name:

--option=value
-option=value
-ovalue

argparse also supports abbreviation of long options (enabled by default):

--opt value
-opt value

Abbreviated double-dash long options can be used with =:

--opt=value

But this does not work with single-dash long options:

-opt=value

This is definitely an omission. There are other bugs related to abbreviation (#104860) and use with = (#124305). There were many other bugs related to this code. This code is just not well tested.

The code for --opt=value is not tested as well -- breaking it does not break tests.

Linked PRs

@serhiy-storchaka serhiy-storchaka added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error labels Sep 23, 2024
@serhiy-storchaka serhiy-storchaka self-assigned this Sep 23, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 24, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 29, 2024
…in argparse (pythonGH-124428)

(cherry picked from commit 6118044)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 29, 2024
…in argparse (pythonGH-124428)

(cherry picked from commit 6118044)

Co-authored-by: Serhiy Storchaka <[email protected]>
@github-project-automation github-project-automation bot moved this to Doc issues in Argparse issues Sep 29, 2024
serhiy-storchaka added a commit that referenced this issue Sep 29, 2024
… in argparse (GH-124428) (GH-124754)

(cherry picked from commit 6118044)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this issue Oct 7, 2024
… in argparse (GH-124428) (GH-124753)

(cherry picked from commit 6118044)

Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
Status: Doc issues
Development

No branches or pull requests

1 participant