mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
gh-80448: argparse: Fix IndexError on store_true action (#15656)
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>
This commit is contained in:
parent
7f3a4b967c
commit
e02cc6d42a
3 changed files with 7 additions and 2 deletions
|
@ -1997,7 +1997,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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue