https://github.com/python/cpython/commit/10c48a93598883bc8882909f9d5f56f99f9d2c38
commit: 10c48a93598883bc8882909f9d5f56f99f9d2c38
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: savannahostrowski <[email protected]>
date: 2026-08-07T17:54:37Z
summary:

[3.15] gh-155352: Fix inconsistent error messages between parse_args and 
documentation (GH-155353) (#155355)

gh-155352: Fix inconsistent error messages between parse_args and documentation 
(GH-155353)
(cherry picked from commit 4ccb6000881842956152d007013d9507f3099227)

Co-authored-by: Timothy Poon <[email protected]>

files:
M Doc/library/argparse.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index e4a5f4d109b499..1549949c458fe3 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]

Reply via email to