diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-06-09 16:34:07 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-06-09 16:34:07 (GMT) |
commit | f97c59aaba2d93e48cbc6d25f7ff9f9c87f8d0b2 (patch) | |
tree | 44fd2f7567db3c58d2bceb724defb040701bce61 /Lib/argparse.py | |
parent | 8dd8d582e3c6d1dd80f5b958284fcb7260209bf3 (diff) | |
download | cpython-f97c59aaba2d93e48cbc6d25f7ff9f9c87f8d0b2.zip cpython-f97c59aaba2d93e48cbc6d25f7ff9f9c87f8d0b2.tar.gz cpython-f97c59aaba2d93e48cbc6d25f7ff9f9c87f8d0b2.tar.bz2 |
#10424: argument names are now included in the missing argument message
Fix and initial test patch by Michele OrrĂ¹.
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 0658472..f0cfe27 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1969,17 +1969,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # if we didn't consume all the argument strings, there were extras extras.extend(arg_strings[stop_index:]) - # if we didn't use all the Positional objects, there were too few - # arg strings supplied. - if positionals: - self.error(_('too few arguments')) - # make sure all required actions were present - for action in self._actions: - if action.required: - if action not in seen_actions: - name = _get_action_name(action) - self.error(_('argument %s is required') % name) + required_actions = [_get_action_name(action) for action in self._actions + if action.required and action not in seen_actions] + if required_actions: + self.error(_('the following arguments are required: %s') % + ', '.join(required_actions)) # make sure all required groups had one option present for group in self._mutually_exclusive_groups: |