GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inferring dest from a single-dash long option · Issue #138697 · python/cpython

Inferring dest from a single-dash long option #138697

New issue
Copy link
New issue
Copy link
Closed
#138699
Closed
Inferring dest from a single-dash long option#138697
#138699
Copy link
Assignees
serhiy-storchaka
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@serhiy-storchaka
serhiy-storchaka
opened on Sep 9, 2025
Issue body actions

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

  • gh-138697: Fix inferring dest from a single-dash long option in argparse #138699

Activity

  1. serhiy-storchaka
    self-assigned this
    on Sep 9, 2025
  2. serhiy-storchaka
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 9, 2025
  3. serhiy-storchaka
    added this to Argparse issueson Sep 9, 2025
  4. serhiy-storchaka
    added
    3.15bugs and security fixesbugs and security fixes
    on Sep 9, 2025
  5. serhiy-storchaka
    added 2 commits that reference this issue on Sep 9, 2025

    pythongh-138697: Fix inferring dest from a single-dash long option in…

    9987fa1

    pythongh-138697: Fix inferring dest from a single-dash long option in…

    426169f
  6. brianschubert
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 9, 2025
  7. serhiy-storchaka
    linked a pull request that will close this issuegh-138697: Fix inferring dest from a single-dash long option in argparse #138699on Sep 19, 2025
  8. savannahostrowski
    added a commit that references this issue on Nov 20, 2025

    gh-138697: Fix inferring dest from a single-dash long option in argpa…

    77cb39e
  9. savannahostrowski
    closed this as completedin #138699on Nov 20, 2025
  10. github-project-automation
    moved this to Doc issues in Argparse issueson Nov 20, 2025
  11. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-138697: Fix inferring dest from a single-dash long option in…

    3d5d18e
  12. ashm-dev
    added a commit that references this issue on Dec 8, 2025

    pythongh-138697: Fix inferring dest from a single-dash long option in…

    23e14ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

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

Projects

  • Argparse issues
    Status
    Doc issues
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.