paul j3 added the comment:

This patch modifies that '--' handling from 13922, removing '--' from PARSER 
and REMAINDER if it is the first string:

        if action.nargs not in [PARSER, REMAINDER]:
            try:
                arg_strings.remove('--')
            except ValueError:
                pass
        else:
            # remove '--' if it is the first string, issue9571
            if arg_strings and arg_strings[0] == '--':
                arg_strings = arg_strings[1:]

Doing this for PARSER addresses this issue, and should not have any backward 
compatibility issues, since starting a 'A...' list with '--' does not make 
sense.

The argument for doing this with REMAINDER is a bit weaker.  I can't think of 
why a user would expect or want an initial '--', but someone might have written 
code to compensate for this flaw.

test_argparse has 2 new tests, added at the end of the subparsers class.  The 
one for subparser has to contend with a bug that makes subparsers optional 
(http://bugs.python.org/issue9253).  The REMAINDER one is clearly related, 
though it doesn't fit the test class theme.

----------
keywords: +patch
Added file: http://bugs.python.org/file35886/issue9571_1.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9571>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to