summaryrefslogtreecommitdiffstats
path: root/Lib/cProfile.py
diff options
context:
space:
mode:
authorStéphane Wirtel <stephane@wirtel.be>2018-10-17 11:48:52 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-10-17 11:48:52 (GMT)
commit669fa8b6376ee8703ae4383536dfcc0e96e51b78 (patch)
treea1e377ff69dec7469cd2a7788302f700d33ed722 /Lib/cProfile.py
parentae011e00189d9083dd84c357718264e24fe77314 (diff)
downloadcpython-669fa8b6376ee8703ae4383536dfcc0e96e51b78.zip
cpython-669fa8b6376ee8703ae4383536dfcc0e96e51b78.tar.gz
cpython-669fa8b6376ee8703ae4383536dfcc0e96e51b78.tar.bz2
[3.6] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (GH-9925) (GH-9927)
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)
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-xLib/cProfile.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 6ae8512..a6d4476 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -121,7 +121,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)
@@ -130,7 +130,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()