Bug 1160640
| Summary: | cProfile main() traceback if options syntax is invalid | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Alexander Todorov <atodorov> | |
| Component: | python | Assignee: | Robert Kuska <rkuska> | |
| Status: | CLOSED ERRATA | QA Contact: | Branislav NĂ¡ter <bnater> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 6.6 | CC: | bkabrda, bnater, jberan, rkuska | |
| Target Milestone: | rc | |||
| Target Release: | --- | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | python-2.6.6-57.el6 | Doc Type: | Bug Fix | |
| Doc Text: |
Cause:
cProfile doesn't output meaningful message when -s option is used without value
Consequence:
when cProfile's option -s is used without value it fails with vague error message
Fix:
when cProfile's option -s is used without value print error valuable error message
Result:
cProfile now prints to stdout all values which -s option supports when not supported is used or forgotten
|
Story Points: | --- | |
| Clone Of: | ||||
| : | 1237107 1319655 1355692 1565101 (view as bug list) | Environment: | ||
| Last Closed: | 2015-07-22 06:39:56 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 1237107, 1565101 | |||
devel_ack+, we can easily fix this. Is this output sufficient?
> $ python -m cProfile -s sdds.py
Usage: cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ...
cProfile.py: error: option -s: invalid choice: 'sdds.py' (choose from 'cumulative', 'module', 'ncalls', 'pcalls', 'file', 'line', 'name', 'calls', 'stdname', 'nfl', 'filename', 'cumtime', 'time', 'tottime')
(In reply to Robert Kuska from comment #3) > Is this output sufficient? > works for me > > $ python -m cProfile -s sdds.py > Usage: cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ... > > cProfile.py: error: option -s: invalid choice: 'sdds.py' (choose from > 'cumulative', 'module', 'ncalls', 'pcalls', 'file', 'line', 'name', 'calls', > 'stdname', 'nfl', 'filename', 'cumtime', 'time', 'tottime') Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2015-1330.html |
Description of problem: I've forgotten to add the sort value to the -s option of cProfile which results in a traceback instead of user friendly error message. In the example below hello.py just prints a "Hello World": $ python -m cProfile -s hello.py Traceback (most recent call last): File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code exec code in run_globals File "/usr/lib64/python2.6/cProfile.py", line 190, in <module> main() File "/usr/lib64/python2.6/cProfile.py", line 185, in main parser.print_usage() File "/usr/lib64/python2.6/optparse.py", line 1597, in print_usage print >>file, self.get_usage() File "/usr/lib64/python2.6/optparse.py", line 1583, in get_usage self.expand_prog_name(self.usage)) File "/usr/lib64/python2.6/optparse.py", line 1560, in expand_prog_name return s.replace("%prog", self.get_prog_name()) File "/usr/lib64/python2.6/optparse.py", line 1555, in get_prog_name return os.path.basename(sys.argv[0]) IndexError: list index out of range Version-Release number of selected component (if applicable): python-2.6.6-52.el6.x86_64 How reproducible: always In addition to this the list of possible sort values is not available and one needs to dig into the code to figure it out.