Skip to content

Commit 4ccb600

Browse files
authored
gh-155352: Fix inconsistent error messages between parse_args and documentation (#155353)
1 parent 7922b67 commit 4ccb600

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
@@ -1564,12 +1564,12 @@ it exits and prints the error along with a usage message::
15641564
>>> # invalid option
15651565
>>> parser.parse_args(['--bar'])
15661566
usage: PROG [-h] [--foo FOO] [bar]
1567-
PROG: error: no such option: --bar
1567+
PROG: error: unrecognized arguments: --bar
15681568

15691569
>>> # wrong number of arguments
15701570
>>> parser.parse_args(['spam', 'badger'])
15711571
usage: PROG [-h] [--foo FOO] [bar]
1572-
PROG: error: extra arguments found: badger
1572+
PROG: error: unrecognized arguments: badger
15731573

15741574

15751575
Arguments containing ``-``
@@ -1606,7 +1606,7 @@ there are no options in the parser that look like negative numbers::
16061606
>>> # negative number options present, so -2 is an option
16071607
>>> parser.parse_args(['-2'])
16081608
usage: PROG [-h] [-1 ONE] [foo]
1609-
PROG: error: no such option: -2
1609+
PROG: error: unrecognized arguments: -2
16101610

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

0 commit comments

Comments
 (0)