diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-11-20 13:48:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 13:48:25 (GMT) |
commit | 836f137f7ae0799de937e5281cb1da2bfdb8a69d (patch) | |
tree | 6516455abc7bf32a38f034f0899b73ffdc46ef8b /Lib | |
parent | daf7a082b20e59a0518cda1500add42c36ab058f (diff) | |
download | cpython-836f137f7ae0799de937e5281cb1da2bfdb8a69d.zip cpython-836f137f7ae0799de937e5281cb1da2bfdb8a69d.tar.gz cpython-836f137f7ae0799de937e5281cb1da2bfdb8a69d.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')
-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 e590225..fd61bc7 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -2093,10 +2093,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 |