diff options
author | Stéphane Wirtel <stephane@wirtel.be> | 2018-10-17 11:51:28 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-17 11:51:28 (GMT) |
commit | 6e57382464101d2669a425622e19fff57586b2ff (patch) | |
tree | dd4d25911c8078381b33463401bbbef6cb68c776 /Lib/cProfile.py | |
parent | f82c9f1e1af8d35056a6961281d72467b4c46b8d (diff) | |
download | cpython-6e57382464101d2669a425622e19fff57586b2ff.zip cpython-6e57382464101d2669a425622e19fff57586b2ff.tar.gz cpython-6e57382464101d2669a425622e19fff57586b2ff.tar.bz2 |
[2.7] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (GH-9925) (GH-9928)
Verify the value for the parameter '-s' of the cProfile CLI. Patch by Robert
Kuska.
Co-authored-by: Robert Kuska <rkuska@gmail.com>
(cherry picked from commit fcd5e84a515e19409840c570730f0728e9fcfc83)
https://bugs.python.org/issue23420
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-x | Lib/cProfile.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py index d377094..cd53cc0 100755 --- a/Lib/cProfile.py +++ b/Lib/cProfile.py @@ -161,7 +161,7 @@ def label(code): # ____________________________________________________________ def main(): - import os, sys + import os, sys, pstats from optparse import OptionParser usage = "cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." parser = OptionParser(usage=usage) @@ -170,7 +170,8 @@ def main(): help="Save stats to <outfile>", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort order when printing to stdout, based on pstats.Stats class", - default=-1) + default=-1, + choices=sorted(pstats.Stats.sort_arg_dict_default)) if not sys.argv[1:]: parser.print_usage() |