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 with subcommands difference in python 2.7 / 3.5 #72397

Open
stephan mannequin opened this issue Sep 20, 2016 · 5 comments
Open

argparse with subcommands difference in python 2.7 / 3.5 #72397

stephan mannequin opened this issue Sep 20, 2016 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@stephan
Copy link
Mannequin

stephan mannequin commented Sep 20, 2016

BPO 28210
Nosy @bitdancer, @timgraham, @Mariatta
Files
  • test_argparse.py
  • 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 2016-09-20.08:43:54.408>
    labels = ['type-bug']
    title = 'argparse with subcommands difference in python 2.7 / 3.5'
    updated_at = <Date 2016-09-28.21:12:42.761>
    user = 'https://bugs.python.org/stephan'

    bugs.python.org fields:

    activity = <Date 2016-09-28.21:12:42.761>
    actor = 'Mariatta'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2016-09-20.08:43:54.408>
    creator = 'stephan'
    dependencies = []
    files = ['44751']
    hgrepos = []
    issue_num = 28210
    keywords = []
    message_count = 5.0
    messages = ['277017', '277028', '277099', '277154', '277566']
    nosy_count = 5.0
    nosy_names = ['r.david.murray', 'paul.j3', 'Tim.Graham', 'stephan', 'Mariatta']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue28210'
    versions = ['Python 2.7', 'Python 3.5']

    @stephan
    Copy link
    Mannequin Author

    stephan mannequin commented Sep 20, 2016

    In python 2.7.12 I get an error if I do not pass
    arguments, while in python 3.5.2 I do not get
    the error (it fails silently).
    Stumbled on this during my migration of my python 2.7 code to python 3.5 for django.

    Here is the console output:

    D:\util\python\test>py -3 test_argparse.py
    3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)]
    Use subparsers: True
    Namespace(command=None)

    D:\util\python\test>py -2 test_argparse.py
    2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
    Use subparsers: True
    usage: test_argparse.py [-h] command ...
    test_argparse.py: error: too few arguments

    D:\util\python\test>

    @stephan stephan mannequin added the type-bug An unexpected behavior, bug, or error label Sep 20, 2016
    @timgraham
    Copy link
    Mannequin

    timgraham mannequin commented Sep 20, 2016

    The behavior change is from bpo-10424. Do you believe the new behavior is incorrect?

    @stephan
    Copy link
    Mannequin Author

    stephan mannequin commented Sep 21, 2016

    I am not an expert with argparse since I just started using it
    (and it has quite a lot of features which are
    not all self-explaining to me).

    But if I didn't misunderstand something it should behave like the python 2.7 version:
    If I do not pass any command I am told that I missed the parameter.

    Or:

    • are there some parameters I missed to make them behave equally?
    • what is the intention to fail silently?

    @timgraham
    Copy link
    Mannequin

    timgraham mannequin commented Sep 21, 2016

    Based on the usage output, it looks like the subcommand is required, but I'm not sure if there are cases where a subcommand could be optional. David, can you advise?

    usage: test_argparse.py [-h] command ...

    @paulj3
    Copy link
    Mannequin

    paulj3 mannequin commented Sep 27, 2016

    Yes there was/is a bug that made subparsers optional.

    http://bugs.python.org/issue9253

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 23, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    Status: Bugs
    Development

    No branches or pull requests

    1 participant