Skip to content
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

argparse: allow_abbrev=False is ignored for alternative prefix characters #83727

Closed
kyleam mannequin opened this issue Feb 3, 2020 · 4 comments
Closed

argparse: allow_abbrev=False is ignored for alternative prefix characters #83727

kyleam mannequin opened this issue Feb 3, 2020 · 4 comments
Labels
3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@kyleam
Copy link
Mannequin

kyleam mannequin commented Feb 3, 2020

BPO 39546
Nosy @rhettinger, @miss-islington, @shihai1991, @kyleam
PRs
  • bpo-39546: argparse: Honor allow_abbrev=False for specified prefix_chars #18337
  • [3.8] bpo-39546: argparse: Honor allow_abbrev=False for specified prefix_chars (GH-18337) #18543
  • 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 = <Date 2020-03-03.16:30:56.744>
    created_at = <Date 2020-02-03.20:11:28.709>
    labels = ['3.8', 'type-bug', 'library', '3.9']
    title = 'argparse: allow_abbrev=False is ignored for alternative prefix characters'
    updated_at = <Date 2020-03-03.16:30:56.744>
    user = 'https://github.com/kyleam'

    bugs.python.org fields:

    activity = <Date 2020-03-03.16:30:56.744>
    actor = 'petr.viktorin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-03.16:30:56.744>
    closer = 'petr.viktorin'
    components = ['Library (Lib)']
    creation = <Date 2020-02-03.20:11:28.709>
    creator = 'kyleam'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39546
    keywords = ['patch']
    message_count = 4.0
    messages = ['361326', '361345', '362183', '362193']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'paul.j3', 'miss-islington', 'shihai1991', 'kyleam']
    pr_nums = ['18337', '18543']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39546'
    versions = ['Python 3.8', 'Python 3.9']

    @kyleam
    Copy link
    Mannequin Author

    kyleam mannequin commented Feb 3, 2020

    As of Python v3.8.0 (specifically commit b1e4d1b), specifying
    allow_abbrev=False does not disable abbreviation for prefix
    characters other than '-'.

    --8<---------------cut here---------------start------------->8---

    import argparse
    
    parser = argparse.ArgumentParser(prefix_chars='+', allow_abbrev=False)
    parser.add_argument('++long')
    print(parser.parse_args(['++lo=val']))
    --8<---------------cut here---------------end--------------->8

    Observed output (with b1e4d1b and current master):

        Namespace(long='val')

    Expected (and observed with b1e4d1b^ and 3.7.3):

    usage: scratch.py [+h] [++long LONG]
    scratch.py: error: unrecognized arguments: ++lo=val
    

    I will follow up with a PR to propose a fix.

    @kyleam kyleam mannequin added 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 3, 2020
    @shihai1991
    Copy link
    Member

    Good catch, it apprears in my python env(master base) too.

    @miss-islington
    Copy link
    Contributor

    New changeset 8edfc47 by Kyle Meyer in branch 'master':
    bpo-39546: argparse: Honor allow_abbrev=False for specified prefix_chars (GH-18337)
    8edfc47

    @miss-islington
    Copy link
    Contributor

    New changeset e412cbb by Miss Islington (bot) in branch '3.8':
    [3.8] bpo-39546: argparse: Honor allow_abbrev=False for specified prefix_chars (GH-18337) (GH-18543)
    e412cbb

    @encukou encukou closed this as completed Mar 3, 2020
    @encukou encukou closed this as completed Mar 3, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants