Message222478
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. |
|
Date |
User |
Action |
Args |
2014-07-07 17:12:55 | paul.j3 | set | recipients:
+ paul.j3, bethard, eric.araujo, r.david.murray, elsdoerfer |
2014-07-07 17:12:55 | paul.j3 | set | messageid: <1404753175.85.0.93705569942.issue9571@psf.upfronthosting.co.za> |
2014-07-07 17:12:55 | paul.j3 | link | issue9571 messages |
2014-07-07 17:12:55 | paul.j3 | create | |
|