mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-38821: Fix crash in argparse when using gettext (GH-17192)
This commit is contained in:
parent
4dedd0f0dd
commit
be5c79e033
2 changed files with 4 additions and 2 deletions
|
@ -2148,10 +2148,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
OPTIONAL: _('expected at most one argument'),
|
||||
ONE_OR_MORE: _('expected at least one argument'),
|
||||
}
|
||||
default = ngettext('expected %s argument',
|
||||
msg = nargs_errors.get(action.nargs)
|
||||
if msg is None:
|
||||
msg = ngettext('expected %s argument',
|
||||
'expected %s arguments',
|
||||
action.nargs) % action.nargs
|
||||
msg = nargs_errors.get(action.nargs, default)
|
||||
raise ArgumentError(action, msg)
|
||||
|
||||
# return the number of arguments matched
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue