#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:48:35 -04:00
parent b94082a71b
commit 00528e8fec
4 changed files with 35 additions and 14 deletions

View file

@ -2186,9 +2186,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: