diff options
author | Federico Bond <federicobond@gmail.com> | 2019-11-20 13:29:29 (GMT) |
---|---|---|
committer | Tal Einat <taleinat+github@gmail.com> | 2019-11-20 13:29:29 (GMT) |
commit | be5c79e0338005d675a64ba6e5b137e850d556d1 (patch) | |
tree | c8418cd2f3afb3d67fbfde4c125edda37433e9a8 /Lib/argparse.py | |
parent | 4dedd0f0ddc5a983a57bf0105eb34f948a91d2c4 (diff) | |
download | cpython-be5c79e0338005d675a64ba6e5b137e850d556d1.zip cpython-be5c79e0338005d675a64ba6e5b137e850d556d1.tar.gz cpython-be5c79e0338005d675a64ba6e5b137e850d556d1.tar.bz2 |
bpo-38821: Fix crash in argparse when using gettext (GH-17192)
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 94e1b8a..5a8eff2 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -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 |