[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

paul j3 report at bugs.python.org
Tue Apr 22 08:33:18 CEST 2014


paul j3 added the comment:

http://bugs.python.org/issue15112
breaks one test that I added to issue

    +class TestPositionalsAfterOptionalsPlus(ParserTestCase):
    +    """Tests specifying a positional that follows an arg with nargs=+
    +    http://bugs.python.org/issue9338#msg111270
    +    prototypical problem"""
    +
    +    argument_signatures = [
    +        Sig('-w'),
    +        Sig('-x', nargs='+'),
    +        Sig('y', type=int),
    +        Sig('z', nargs='*', type=int)]
    +    failures = ['1 -x 2 3 -w 4 5 6' # error: unrecognized arguments: 5 6
    +                # z consumed in 1st argument group '1'
    +    ]

This no longer fails.  Due to 15112, z=[5,6].  That is, it is no longer consumed by the 1st argument group.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9338>
_______________________________________


More information about the Python-bugs-list mailing list