https://github.com/python/cpython/commit/4ccb6000881842956152d007013d9507f3099227
commit: 4ccb6000881842956152d007013d9507f3099227
branch: main
author: Timothy Poon <[email protected]>
committer: savannahostrowski <[email protected]>
date: 2026-08-07T17:48:07Z
summary:
gh-155352: Fix inconsistent error messages between parse_args and documentation
(#155353)
files:
M Doc/library/argparse.rst
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 8ae96311026f33..0eba8ca932be1f 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1564,12 +1564,12 @@ it exits and prints the error along with a usage
message::
>>> # invalid option
>>> parser.parse_args(['--bar'])
usage: PROG [-h] [--foo FOO] [bar]
- PROG: error: no such option: --bar
+ PROG: error: unrecognized arguments: --bar
>>> # wrong number of arguments
>>> parser.parse_args(['spam', 'badger'])
usage: PROG [-h] [--foo FOO] [bar]
- PROG: error: extra arguments found: badger
+ PROG: error: unrecognized arguments: badger
Arguments containing ``-``
@@ -1606,7 +1606,7 @@ there are no options in the parser that look like
negative numbers::
>>> # negative number options present, so -2 is an option
>>> parser.parse_args(['-2'])
usage: PROG [-h] [-1 ONE] [foo]
- PROG: error: no such option: -2
+ PROG: error: unrecognized arguments: -2
>>> # negative number options present, so both -1s are options
>>> parser.parse_args(['-1', '-1'])
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]