aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib-python/3/argparse.py')
-rw-r--r--lib-python/3/argparse.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib-python/3/argparse.py b/lib-python/3/argparse.py
index a030749247..ac424f4914 100644
--- a/lib-python/3/argparse.py
+++ b/lib-python/3/argparse.py
@@ -407,13 +407,19 @@ class HelpFormatter(object):
inserts[start] += ' ['
else:
inserts[start] = '['
- inserts[end] = ']'
+ if end in inserts:
+ inserts[end] += ']'
+ else:
+ inserts[end] = ']'
else:
if start in inserts:
inserts[start] += ' ('
else:
inserts[start] = '('
- inserts[end] = ')'
+ if end in inserts:
+ inserts[end] += ')'
+ else:
+ inserts[end] = ')'
for i in range(start + 1, end):
inserts[i] = '|'
@@ -2074,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