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

python -mtrace --help is wrong #68837

Closed
anntzer mannequin opened this issue Jul 16, 2015 · 4 comments
Closed

python -mtrace --help is wrong #68837

anntzer mannequin opened this issue Jul 16, 2015 · 4 comments
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Jul 16, 2015

BPO 24649
Nosy @abalkin, @anntzer
Superseder
  • bpo-22642: trace module: convert to argparse
  • Files
  • issue24649.patch
  • 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 2016-01-12.10:17:07.084>
    created_at = <Date 2015-07-16.22:43:05.197>
    labels = ['easy', 'type-bug', 'library']
    title = 'python -mtrace --help is wrong'
    updated_at = <Date 2016-01-12.10:17:07.082>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2016-01-12.10:17:07.082>
    actor = 'SilentGhost'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-01-12.10:17:07.084>
    closer = 'SilentGhost'
    components = ['Library (Lib)']
    creation = <Date 2015-07-16.22:43:05.197>
    creator = 'Antony.Lee'
    dependencies = []
    files = ['40125']
    hgrepos = []
    issue_num = 24649
    keywords = ['patch', 'easy']
    message_count = 4.0
    messages = ['246834', '246952', '248003', '258098']
    nosy_count = 4.0
    nosy_names = ['belopolsky', 'SilentGhost', 'Antony.Lee', 'Evan Hubinger']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = '22642'
    type = 'behavior'
    url = 'https://bugs.python.org/issue24649'
    versions = ['Python 3.6']

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented Jul 16, 2015

    While working on bpo-24644, I noticed that the help for python -mtrace is quite wrong.

    $ python -mtrace --help
    Usage: /usr/lib/python3.4/trace.py [OPTIONS] <file> [ARGS]

    Meta-options:
    --help Display this help then exit.
    --version Output version information then exit.

    Otherwise, exactly one of the following three options must be given:
    -t, --trace Print each line to sys.stdout before it is executed.
    -c, --count Count the number of times each line is executed
    and write the counts to .cover for each
    module executed, in the module's directory.
    See also --coverdir', --file', --no-report' below. -l, --listfuncs Keep track of which functions are executed at least once and write the results to sys.stdout after the program exits. -T, --trackcalls Keep track of caller/called pairs and write the results to sys.stdout after the program exits. -r, --report Generate a report from a counts file; do not execute any code. --file' must specify the results file to
    read, which must have been created in a previous run
    with `--count --file=FILE'.

    <elided modifier flags>

    1. Obviously, there are more than 3 options there.
    2. Simple testing suggests that it is at least possible to pass both -t and -c simultaneously. I haven't tested other combinations.

    @anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Jul 16, 2015
    @abalkin
    Copy link
    Member

    abalkin commented Jul 20, 2015

    Maybe it is time to rewrite trace module argument parser using argparse
    and get an "always correct" auto-generated help for free?

    @abalkin abalkin added the easy label Jul 20, 2015
    @EvanHubinger
    Copy link
    Mannequin

    EvanHubinger mannequin commented Aug 4, 2015

    Added a patch that clears up the incorrect help. It now accurately reflects the only constraints that the code actually puts on the arguments:

        if listfuncs and (count or trace):
            _err_exit("cannot specify both --listfuncs and (--trace or --count)")
    
        if not (count or trace or report or listfuncs or countcallers):
            _err_exit("must specify one of --trace, --count, --report, "
                      "--listfuncs, or --trackcalls")

    To reflect both of those constraints, and only those constraints, the part of the help message in question now reads:

    Otherwise, at least one of the following options must be given:
    -t, --trace Print each line to sys.stdout before it is executed.
    -c, --count Count the number of times each line is executed
    and write the counts to .cover for each
    module executed, in the module's directory.
    See also --coverdir', --file', --no-report' below. -l, --listfuncs Keep track of which functions are executed at least once and write the results to sys.stdout after the program exits. Cannot be specified alongside --traceor--count. -T, --trackcalls Keep track of caller/called pairs and write the results to sys.stdout after the program exits. -r, --report Generate a report from a counts file; do not execute any code. --file' must specify the results file to
    read, which must have been created in a previous run
    with `--count --file=FILE'.

    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Jan 12, 2016

    A re-write using argparse is submitted in the bpo-22642, that's why I'm closing this issue. Changes from Evan's patch were incorporated in the submitted patch there.

    @SilentGhost SilentGhost mannequin closed this as completed Jan 12, 2016
    @SilentGhost SilentGhost mannequin added the type-bug An unexpected behavior, bug, or error label Jan 12, 2016
    @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
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant