mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
[3.11] gh-109475: Fix support of explicit option value "--" in argparse (GH-114814) (GH-115037)
For example "--option=--".
(cherry picked from commit 4aa4f0906d
)
This commit is contained in:
parent
98b2f4624a
commit
e1976399cd
3 changed files with 20 additions and 1 deletions
|
@ -2464,7 +2464,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
# ========================
|
||||
def _get_values(self, action, arg_strings):
|
||||
# for everything but PARSER, REMAINDER args, strip out first '--'
|
||||
if action.nargs not in [PARSER, REMAINDER]:
|
||||
if not action.option_strings and action.nargs not in [PARSER, REMAINDER]:
|
||||
try:
|
||||
arg_strings.remove('--')
|
||||
except ValueError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue