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

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

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 7508aea2aed084..9709d7e4435770 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1541,12 +1541,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 ``-``
@@ -1583,7 +1583,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