Skip to content

Commit a9a90f9

Browse files
authored
Improve argument handling in pdb.py
1 parent 70eb56b commit a9a90f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/pdb.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,9 +3635,14 @@ def parse_args():
36353635
opts.module = opt_module.module
36363636
args = args[2:]
36373637
elif args[0].startswith('-'):
3638-
# Invalid argument before the script name.
3639-
invalid_args = list(itertools.takewhile(lambda a: a.startswith('-'), args))
3640-
parser.error(f"unrecognized arguments: {' '.join(invalid_args)}")
3638+
if args[0] == '--':
3639+
args.pop(0)
3640+
if not args:
3641+
parser.error("missing script or module to run")
3642+
else:
3643+
# Invalid argument before the script name.
3644+
invalid_args = list(itertools.takewhile(lambda a: a.startswith('-'), args))
3645+
parser.error(f"unrecognized arguments: {' '.join(invalid_args)}")
36413646

36423647
# Otherwise it's debugging a script and we already parsed all -c commands.
36433648

0 commit comments

Comments
 (0)