diff options
author | Stéphane Wirtel <stephane@wirtel.be> | 2018-10-17 10:03:40 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-17 10:03:40 (GMT) |
commit | fcd5e84a515e19409840c570730f0728e9fcfc83 (patch) | |
tree | 7e21db82d894544759edc23cc13ccbe108d224d2 /Lib/cProfile.py | |
parent | 8e73ad38ab7d218b9ef8976032865928dfad00f1 (diff) | |
download | cpython-fcd5e84a515e19409840c570730f0728e9fcfc83.zip cpython-fcd5e84a515e19409840c570730f0728e9fcfc83.tar.gz cpython-fcd5e84a515e19409840c570730f0728e9fcfc83.tar.bz2 |
bpo-23420: 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>
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 3c9be3c..305e79e 100755 --- a/Lib/cProfile.py +++ b/Lib/cProfile.py @@ -131,6 +131,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) @@ -139,7 +140,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) |