diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-11 18:16:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 18:16:18 -0800 |
commit | 8d27e6294b73fa2b5c6ecbeee072bb05c30d2685 (patch) | |
tree | 1dbbfd6aa36f71394b88f92bd31d8c2dc8c0b919 /Lib/argparse.py | |
parent | gh-87604: Clarify in docs that sys.addaudithook is not for sandboxes (GH-99372) (diff) | |
download | cpython-8d27e6294b73fa2b5c6ecbeee072bb05c30d2685.tar.gz cpython-8d27e6294b73fa2b5c6ecbeee072bb05c30d2685.tar.bz2 cpython-8d27e6294b73fa2b5c6ecbeee072bb05c30d2685.zip |
gh-80448: argparse: Fix IndexError on store_true action (GH-15656)
(cherry picked from commit e02cc6d42aee1f0a9ee629f76576eee478224d9d)
Co-authored-by: Hai Shi <shihai1992@gmail.com>
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 9be18488abe..fb042a86b47 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1962,7 +1962,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # arguments, try to parse more single-dash options out # of the tail of the option string chars = self.prefix_chars - if arg_count == 0 and option_string[1] not in chars: + if ( + arg_count == 0 + and option_string[1] not in chars + and explicit_arg != '' + ): action_tuples.append((action, [], option_string)) char = option_string[0] option_string = char + explicit_arg[0] |