diff -r 95d1adf144ee Lib/argparse.py --- a/Lib/argparse.py Sat Nov 03 14:37:37 2012 +0200 +++ b/Lib/argparse.py Sat Nov 03 16:57:54 2012 +0100 @@ -2229,7 +2229,11 @@ value = action.default else: value = arg_strings - self._check_value(action, value) + if not isinstance(value, list): + self._check_value(action, value) + else: + for v in value: + self._check_value(action, v) # single argument or optional argument produces a single value elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]: diff -r 95d1adf144ee Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Sat Nov 03 14:37:37 2012 +0200 +++ b/Lib/test/test_argparse.py Sat Nov 03 16:57:54 2012 +0100 @@ -819,6 +819,18 @@ ] +class TestPositionalsNargsZeroOrMoreChoices(ParserTestCase): + """Test a Positional that specifies unlimited nargs with choices""" + + argument_signatures = [Sig('foo', nargs='*', choices='abc')] + failures = ['-x', 'spam'] + successes = [ + ('', NS(foo=[])), + ('a', NS(foo=['a'])), + ('a b', NS(foo=['a', 'b'])), + ] + + class TestPositionalsNargsOneOrMore(ParserTestCase): """Test a Positional that specifies one or more nargs""" @@ -830,6 +842,17 @@ ] +class TestPositionalsNargsOneOrMoreChoices(ParserTestCase): + """Test a Positional that specifies one or more nargs with choices""" + + argument_signatures = [Sig('foo', nargs='+', choices='abc')] + failures = ['', '-x', 'spam'] + successes = [ + ('a', NS(foo=['a'])), + ('a b', NS(foo=['a', 'b'])), + ] + + class TestPositionalsNargsOptional(ParserTestCase): """Tests an Optional Positional"""