mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
#13922: argparse no longer incorrectly strips '--' after the first one.
Patch by Jeff Knupp.
This commit is contained in:
parent
b94082a71b
commit
00528e8fec
4 changed files with 35 additions and 14 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue