New submission from py.user:

>>> import argparse
>>> 
>>> parser = argparse.ArgumentParser()
>>> _ = parser.add_argument('foo', choices=[], help='%(choices)s')
>>> parser.print_help()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 2358, in print_help
    self._print_message(self.format_help(), file)
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 2342, in format_help
    return formatter.format_help()
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 278, in format_help
    help = self._root_section.format_help()
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 208, in format_help
    func(*args)
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 208, in format_help
    func(*args)
  File "/home/guest/tmp/tests/misc/git/example/cpython/main/Lib/argparse.py", 
line 517, in _format_action
    parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
IndexError: list index out of range
>>>

It's not very useful to print empty choices, but the choices list could be 
formed dynamically. So the command-line user can't figure out what's happen.

----------
components: Library (Lib)
messages: 245297
nosy: py.user
priority: normal
severity: normal
status: open
title: In argparse empty choices cannot be printed in the help
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to