Skip to content

argparse: potential bugs on add_subparser due to allow_abbrev cannot deal with short options #88767

Closed as not planned

Description

@zhongxiang117
BPO 44601
Nosy @zhongxiang117
Files
  • myargparse.py: reproduce and explanations
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-07-11.23:21:14.214>
    labels = ['3.8', 'type-bug', 'library', '3.9']
    title = 'argparse: potential bugs on add_subparser due to allow_abbrev cannot deal with short options'
    updated_at = <Date 2021-07-11.23:21:14.214>
    user = 'https://github.com/zhongxiang117'

    bugs.python.org fields:

    activity = <Date 2021-07-11.23:21:14.214>
    actor = 'zhongxiang117'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-07-11.23:21:14.214>
    creator = 'zhongxiang117'
    dependencies = []
    files = ['50143']
    hgrepos = []
    issue_num = 44601
    keywords = []
    message_count = 1.0
    messages = ['397268']
    nosy_count = 1.0
    nosy_names = ['zhongxiang117']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44601'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. zhongxiang117 commented on Jul 11, 2021

      zhongxiang117mannequin
      MannequinAuthor

      Additional argument like "allow_abbrev_short" should be added to avoid those potential bugs due to abbreviations on short options cannot be handled by "allow_abbrev".

      To reproduce and be well explanation, please check on my attached testing file.

      The following is the excerpt:

      1. contents in link:
        https://docs.python.org/3/library/argparse.html#prefix-matching
        should be updated to long options (two dashes)

      2. bugs may happen due to allow_abbrev' cannot handle short options when recycling top-level arguments by using add_subparsers'

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Jul 11, 2021
    3. transferred this issue fromon Apr 10, 2022
    4. serhiy-storchaka commented on Sep 26, 2024

      @serhiy-storchaka
      Member

      You used confusing terminology. Short options are options consisting of a dash followed by a single non-dash character. Options starting with a single dash and followed by multiple characters are called single-dash long options. Options starting with a double dash are called double-dash long options. Short options cannot be abbreviated, but they can be grouped.

      allow_abbre=False is broken for single-dash long options, this is a known bug and it will be fixed by #124340.

      Do you have other issues besides allow_abbre=False not working for single-dash long options?

    5. moved this from Bugs to Doc issues in Argparse issueson Oct 9, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)end of life3.9 (EOL)end of lifependingThe issue will be closed if no feedback is providedstdlibStandard 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