diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-11-20 13:48:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 13:48:20 (GMT) |
commit | ecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7 (patch) | |
tree | ce8ab4975686bdf96bfb02b3b593eacda2835280 /Lib/argparse.py | |
parent | 1d7245c3e0cfe4508855c5025b25d8894155ecc5 (diff) | |
download | cpython-ecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7.zip cpython-ecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7.tar.gz cpython-ecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7.tar.bz2 |
bpo-38821: Fix crash in argparse when using gettext (GH-17192)
(cherry picked from commit be5c79e0338005d675a64ba6e5b137e850d556d1)
Co-authored-by: Federico Bond <federicobond@gmail.com>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 24af355..ac424f4 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -2080,10 +2080,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 |