[3.13] gh-125254: Fix error report about ambiguous option in argparse (GH-125273) (GH-125359)

This was a regression introduced in gh-58573. It was only tested for the
case when the ambiguous option is the last argument in the command line.
(cherry picked from commit 63cf4e914f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-10-12 15:00:41 +02:00 committed by GitHub
parent b4c504d76f
commit 33c41360c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -2011,7 +2011,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
if len(option_tuples) > 1:
options = ', '.join([option_string
for action, option_string, sep, explicit_arg in option_tuples])
args = {'option': arg_string, 'matches': options}
args = {'option': arg_strings[start_index], 'matches': options}
msg = _('ambiguous option: %(option)s could match %(matches)s')
raise ArgumentError(None, msg % args)