diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-09-29 07:52:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-29 07:52:07 (GMT) |
commit | 61180446eee2aef07b042c7e8892c45afabd1499 (patch) | |
tree | 9d27af208c29c77fa353e8d3f231a4c384958aef /Lib/argparse.py | |
parent | 9bcadf589ab6f7b9d309290de7a80156b6905d35 (diff) | |
download | cpython-61180446eee2aef07b042c7e8892c45afabd1499.zip cpython-61180446eee2aef07b042c7e8892c45afabd1499.tar.gz cpython-61180446eee2aef07b042c7e8892c45afabd1499.tar.bz2 |
gh-124345: Support abbreviated single-dash long options with = in argparse (GH-124428)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 3c2023e..715d2ba 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -2319,7 +2319,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:] @@ -2330,7 +2332,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 |