-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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 -m cProfile -s fails with non informative message #67608
Comments
Originaly reported here: https://bugzilla.redhat.com/show_bug.cgi?id=1160640 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 Tested with python2.7, python3.4 with the same result. Attached patch adds
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') |
Any info regarding that? Patch seems good and it actually works. |
Patch looks good to me, but we need a test case. |
Hi, Just used the content of the patch and apply it on master, |
Thanks Robert Kuska for the bug report and the initial patch, thanks Stéphane Wirtel for the PR (with the NEWS entry and the new test ;-)) |
welcome |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: