diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-10-17 16:11:03 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-10-17 16:11:03 (GMT) |
commit | 1f6b69b74996164be5f13dea34242edc14bd87a1 (patch) | |
tree | b1b50209870de40fc64e71aacc84b8a9785c3266 /Lib/test/regrtest.py | |
parent | 5493e4723a922b9905cf6916363e72109a531cfd (diff) | |
download | cpython-1f6b69b74996164be5f13dea34242edc14bd87a1.zip cpython-1f6b69b74996164be5f13dea34242edc14bd87a1.tar.gz cpython-1f6b69b74996164be5f13dea34242edc14bd87a1.tar.bz2 |
Issue #28409: regrtest: fix the parser of command line arguments.
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-x | Lib/test/regrtest.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index f1892ac..f870854 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -325,9 +325,6 @@ def _create_parser(): group.add_argument('-P', '--pgo', dest='pgo', action='store_true', help='enable Profile Guided Optimization training') - parser.add_argument('args', nargs='*', - help=argparse.SUPPRESS) - return parser def relative_filename(string): @@ -373,7 +370,13 @@ def _parse_args(args, **kwargs): ns.use_resources = [] parser = _create_parser() - parser.parse_args(args=args, namespace=ns) + # Issue #14191: argparse doesn't support "intermixed" positional and + # optional arguments. Use parse_known_args() as workaround. + ns.args = parser.parse_known_args(args=args, namespace=ns)[1] + for arg in ns.args: + if arg.startswith('-'): + parser.error("unrecognized arguments: %s" % arg) + sys.exit(1) if ns.single and ns.fromfile: parser.error("-s and -f don't go together!") |