[issue26952] argparse help formatter crashes
Alexander Kapshuna
report at bugs.python.org
Sun Jul 7 06:14:49 EDT 2019
Alexander Kapshuna <kapsh at kap.sh> added the comment:
I have a feeling that nesting groups has nothing to do with it. Got same traceback when I forgot to fill my mutually exclusive groups with arguments.
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
parser.parse_args(['-h'])
# Result:
Traceback (most recent call last):
File "/home/kapsh/.PyCharmCE2019.1/config/scratches/scratch_12.py", line 5, in <module>
parser.parse_args(['-h'])
File "/usr/lib/python3.7/argparse.py", line 1749, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/lib/python3.7/argparse.py", line 1781, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib/python3.7/argparse.py", line 1987, in _parse_known_args
start_index = consume_optional(start_index)
File "/usr/lib/python3.7/argparse.py", line 1927, in consume_optional
take_action(action, args, option_string)
File "/usr/lib/python3.7/argparse.py", line 1855, in take_action
action(self, namespace, argument_values, option_string)
File "/usr/lib/python3.7/argparse.py", line 1037, in __call__
parser.print_help()
File "/usr/lib/python3.7/argparse.py", line 2474, in print_help
self._print_message(self.format_help(), file)
File "/usr/lib/python3.7/argparse.py", line 2458, in format_help
return formatter.format_help()
File "/usr/lib/python3.7/argparse.py", line 284, in format_help
help = self._root_section.format_help()
File "/usr/lib/python3.7/argparse.py", line 215, in format_help
item_help = join([func(*args) for func, args in self.items])
File "/usr/lib/python3.7/argparse.py", line 215, in <listcomp>
item_help = join([func(*args) for func, args in self.items])
File "/usr/lib/python3.7/argparse.py", line 322, in _format_usage
action_usage = format(optionals + positionals, groups)
File "/usr/lib/python3.7/argparse.py", line 397, in _format_actions_usage
start = actions.index(group._group_actions[0])
IndexError: list index out of range
----------
nosy: +kapsh
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue26952>
_______________________________________
More information about the Python-bugs-list
mailing list