mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-124345: Support abbreviated single-dash long options with = in argparse (GH-124428) (GH-124753)
(cherry picked from commit 61180446ee
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
f28906e58e
commit
597b6211ab
3 changed files with 16 additions and 3 deletions
|
@ -2344,7 +2344,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
# but multiple character options always have to have their argument
|
||||
# separate
|
||||
elif option_string[0] in chars and option_string[1] not in chars:
|
||||
option_prefix = option_string
|
||||
option_prefix, sep, explicit_arg = option_string.partition('=')
|
||||
if not sep:
|
||||
sep = explicit_arg = None
|
||||
short_option_prefix = option_string[:2]
|
||||
short_explicit_arg = option_string[2:]
|
||||
|
||||
|
@ -2355,7 +2357,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
result.append(tup)
|
||||
elif self.allow_abbrev and option_string.startswith(option_prefix):
|
||||
action = self._option_string_actions[option_string]
|
||||
tup = action, option_string, None, None
|
||||
tup = action, option_string, sep, explicit_arg
|
||||
result.append(tup)
|
||||
|
||||
# shouldn't ever get here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue