This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rkuska
Recipients rkuska
Date 2015-02-09.12:05:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Originaly reported here:

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 just prints a "Hello World":

$ python -m cProfile -s
Traceback (most recent call last):
  File "/usr/lib64/python2.6/", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib64/python2.6/", line 190, in <module>
  File "/usr/lib64/python2.6/", line 185, in main
  File "/usr/lib64/python2.6/", line 1597, in print_usage
    print >>file, self.get_usage()
  File "/usr/lib64/python2.6/", line 1583, in get_usage
  File "/usr/lib64/python2.6/", line 1560, in expand_prog_name
    return s.replace("%prog", self.get_prog_name())
  File "/usr/lib64/python2.6/", 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                                                                                                     
Usage: [-o output_file_path] [-s sort] scriptfile [arg] ... error: option -s: invalid choice: '' (choose from 'cumulative', 'module', 'ncalls', 'pcalls', 'file', 'line', 'name', 'calls', 'stdname', 'nfl', 'filename', 'cumtime', 'time', 'tottime')
Date User Action Args
2015-02-09 12:05:42rkuskasetrecipients: + rkuska
2015-02-09 12:05:42rkuskasetmessageid: <>
2015-02-09 12:05:42rkuskalinkissue23420 messages
2015-02-09 12:05:41rkuskacreate