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

argparse.ArgumentParser does not raise on duplicated subparsers, even though it does on duplicated flags · Issue #83897 · python/cpython · GitHub

Repository navigation

argparse.ArgumentParser does not raise on duplicated subparsers, even though it does on duplicated flags #83897

Description

mannequin
BPO 39716
Nosy @rhettinger, @anntzer
PRs
  • gh-83897: Raise on conflicting subparser names. #18605
  • 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 2020-02-21.18:20:54.496>
    labels = ['library', '3.9']
    title = 'argparse.ArgumentParser does not raise on duplicated subparsers, even though it does on duplicated flags'
    updated_at = <Date 2020-02-22.11:04:34.546>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2020-02-22.11:04:34.546>
    actor = 'Antony.Lee'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-02-21.18:20:54.496>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39716
    keywords = ['patch']
    message_count = 3.0
    messages = ['362421', '362428', '362458']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'paul.j3', 'Antony.Lee']
    pr_nums = ['18605']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39716'
    versions = ['Python 3.9']

    Activity

    1. anntzer commented on Feb 21, 2020

      anntzermannequin
      MannequinAuthor

      If one tries to add twice the same flag to an ArgumentParser, one gets a helpful exception:

          from argparse import ArgumentParser
          p = ArgumentParser()
          p.add_argument("--foo")
          p.add_argument("--foo")

      results in

      argparse.ArgumentError: argument --foo: conflicting option string: --foo
      

      However, adding twice the same subparser raises no exception:

          from argparse import ArgumentParser
          p = ArgumentParser()
          sp = p.add_subparsers()
          sp.add_parser("foo")
          sp.add_parser("foo")

      even though the two subparsers shadow one another in the same way as two identical flags.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Feb 21, 2020
    3. rhettinger commented on Feb 21, 2020

      Contributor

      Would you like to work-up a patch to fix this?

    4. anntzer commented on Feb 22, 2020

      anntzermannequin
      MannequinAuthor

      Sure, #18605 it is.

    5. transferred this issue fromon Apr 10, 2022
    6. ppolewicz commented on Nov 11, 2022

      Please note that this issue is labeled as 3.9 and fix for it was submitted in February 2020, but the fix was actually released with 3.11

    7. terryjreedy commented on Aug 16, 2023

      Member

      @ppolewicz PRs are nearly always merged into main and only sometimes backported. Tracker version labels indicate the version(s) reported for, not necessarily the versions patched. Since we moved the repository to github, PR titles indicate the version(s) actually patched (with 'main' the default). The tracker move to github messed up merge reporting for old PRs. I repointed the PR for this issue to the gh number so it is listed immediately above.

    8. serhiy-storchaka commented on Oct 22, 2024

      Member

      This was actually a duplicate of #59061.

    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.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directory

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL