Skip to content

Commit f0d754d

Browse files
ptim0626miss-islington
authored andcommitted
gh-155352: Fix inconsistent error messages between parse_args and documentation (GH-155353)
(cherry picked from commit 4ccb600) Co-authored-by: Timothy Poon <62692924+ptim0626@users.noreply.github.com>
1 parent 2e19855 commit f0d754d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Doc/library/argparse.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,12 +1447,12 @@ it exits and prints the error along with a usage message::
14471447
>>> # invalid option
14481448
>>> parser.parse_args(['--bar'])
14491449
usage: PROG [-h] [--foo FOO] [bar]
1450-
PROG: error: no such option: --bar
1450+
PROG: error: unrecognized arguments: --bar
14511451

14521452
>>> # wrong number of arguments
14531453
>>> parser.parse_args(['spam', 'badger'])
14541454
usage: PROG [-h] [--foo FOO] [bar]
1455-
PROG: error: extra arguments found: badger
1455+
PROG: error: unrecognized arguments: badger
14561456

14571457

14581458
Arguments containing ``-``
@@ -1489,7 +1489,7 @@ there are no options in the parser that look like negative numbers::
14891489
>>> # negative number options present, so -2 is an option
14901490
>>> parser.parse_args(['-2'])
14911491
usage: PROG [-h] [-1 ONE] [foo]
1492-
PROG: error: no such option: -2
1492+
PROG: error: unrecognized arguments: -2
14931493

14941494
>>> # negative number options present, so both -1s are options
14951495
>>> parser.parse_args(['-1', '-1'])

0 commit comments

Comments
 (0)