New submission from Robert Kuska: 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 `choices` for sort option of cProfile. > $ 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') ---------- components: Extension Modules files: sort-choices.patch keywords: patch messages: 235602 nosy: rkuska priority: normal severity: normal status: open title: python -m cProfile -s fails with non informative message type: enhancement versions: Python 2.7, Python 3.4 Added file: http://bugs.python.org/file38053/sort-choices.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23420> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com