mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #28409: regrtest: fix the parser of command line arguments.
This commit is contained in:
parent
5493e4723a
commit
1f6b69b749
3 changed files with 21 additions and 6 deletions
|
@ -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!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue