#13922: argparse no longer incorrectly strips '--' after the first one.

Patch by Jeff Knupp.
This commit is contained in:
R David Murray 2012-07-21 22:54:34 -04:00
parent 056c31f9cc
commit 68f555c03a
4 changed files with 34 additions and 14 deletions

View file

@ -2174,9 +2174,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# Value conversion methods
# ========================
def _get_values(self, action, arg_strings):
# for everything but PARSER args, strip out '--'
# for everything but PARSER, REMAINDER args, strip out first '--'
if action.nargs not in [PARSER, REMAINDER]:
arg_strings = [s for s in arg_strings if s != '--']
try:
arg_strings.remove('--')
except ValueError:
pass
# optional argument produces a default when not present
if not arg_strings and action.nargs == OPTIONAL: