FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Inferring dest from a single-dash long option · Issue #138697 · python/cpython · GitHub

Repository navigation

Inferring dest from a single-dash long option #138697

Closed

Description

Bug report

In argparse, in general, short options are options that consist of a single character preceded by a dash (e.g. -f), and long options are either preceded by a double dash or are longer that a single character (e.g. --foo and -foo). Short option can be combined together and can have value immediately following an option, long options should be separate and have explicit separation from value.

But when dest is inferred from the option strings, single-dash long options are treated as short options. For example, in add_argument('-f', '--foo') dest is 'foo', but in add_argument('-f', '-foo') dest is 'f'.

This inconsistency should be fixed. But since this is a breaking change, it should not be backported.

I doubt it will break much user code (it did not broke existing tests), because it only affects the code that uses both short option and single-dash long option for the same argument, place the short option option first, and does not have explicit dest argument. Users that use short options and single-dash long options most likely use workarounds: either place the single-dash long option first or add an explicit dest argument.

Linked PRs

Activity

  1. added 2 commits that reference this issue on Sep 9, 2025
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 9, 2025
  3. added a commit that references this issue on Nov 20, 2025
  4. added a commit that references this issue on Dec 6, 2025
  5. added a commit that references this issue on Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL