Skip to content

Commit afcec4c

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 87bacf1 commit afcec4c

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
@@ -1541,12 +1541,12 @@ it exits and prints the error along with a usage message::
15411541
>>> # invalid option
15421542
>>> parser.parse_args(['--bar'])
15431543
usage: PROG [-h] [--foo FOO] [bar]
1544-
PROG: error: no such option: --bar
1544+
PROG: error: unrecognized arguments: --bar
15451545

15461546
>>> # wrong number of arguments
15471547
>>> parser.parse_args(['spam', 'badger'])
15481548
usage: PROG [-h] [--foo FOO] [bar]
1549-
PROG: error: extra arguments found: badger
1549+
PROG: error: unrecognized arguments: badger
15501550

15511551

15521552
Arguments containing ``-``
@@ -1583,7 +1583,7 @@ there are no options in the parser that look like negative numbers::
15831583
>>> # negative number options present, so -2 is an option
15841584
>>> parser.parse_args(['-2'])
15851585
usage: PROG [-h] [-1 ONE] [foo]
1586-
PROG: error: no such option: -2
1586+
PROG: error: unrecognized arguments: -2
15871587

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

0 commit comments

Comments
 (0)