Message91240
$ python -m profile
Usage: profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...
$ python -m profile -s calls
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/profile.py", line 619, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/profile.py", line 614, in main
parser.print_usage()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/optparse.py", line 1584, in print_usage
print >>file, self.get_usage()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/optparse.py", line 1570, in get_usage
self.expand_prog_name(self.usage))
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/optparse.py", line 1547, in expand_prog_name
return s.replace("%prog", self.get_prog_name())
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/optparse.py", line 1542, in get_prog_name
return os.path.basename(sys.argv[0])
IndexError: list index out of range
This is triggered by an early override of sys.argv when usage() is called (Lib/profile.py:603):
if not sys.argv[1:]:
parser.print_usage()
sys.exit(2)
(options, args) = parser.parse_args()
sys.argv[:] = args
if (len(sys.argv) > 0):
sys.path.insert(0, os.path.dirname(sys.argv[0]))
run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
else:
parser.print_usage()
return parser
In the "else" branch it tries to print usage but sys.argv[] were already overwritten.
Attached is the proposed patch (tested with 2.5, 2.6, 3.1). |
|
Date |
User |
Action |
Args |
2009-08-03 20:32:41 | pr0gg3d | set | recipients:
+ pr0gg3d |
2009-08-03 20:32:40 | pr0gg3d | set | messageid: <1249331560.84.0.146355793731.issue6635@psf.upfronthosting.co.za> |
2009-08-03 20:32:39 | pr0gg3d | link | issue6635 messages |
2009-08-03 20:32:38 | pr0gg3d | create | |
|