diff options
author | Stéphane Wirtel <stephane@wirtel.be> | 2018-10-17 11:48:05 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-17 11:48:05 (GMT) |
commit | 657e3f9a2c0d620807dd81882d566ad8f1ae423e (patch) | |
tree | beea4d4779aed4150a6cbd4dd8e68b7e3f76a311 /Lib/cProfile.py | |
parent | 514bbfc7fc4dcb868d4364632ad14c0533af154f (diff) | |
download | cpython-657e3f9a2c0d620807dd81882d566ad8f1ae423e.zip cpython-657e3f9a2c0d620807dd81882d566ad8f1ae423e.tar.gz cpython-657e3f9a2c0d620807dd81882d566ad8f1ae423e.tar.bz2 |
[3.7] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (GH-9925) (GH-9926)
[3.7] [bpo-23420](https://bugs.python.org/issue23420): Verify the value of '-s' when execute the CLI of cProfile (GH-9925)
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 | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py index c044be8..f6e423b 100755 --- a/Lib/cProfile.py +++ b/Lib/cProfile.py @@ -124,6 +124,7 @@ def main(): import os import sys import runpy + import pstats from optparse import OptionParser usage = "cProfile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ..." parser = OptionParser(usage=usage) @@ -132,7 +133,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)) parser.add_option('-m', dest="module", action="store_true", help="Profile a library module", default=False) |