This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author py.user
Recipients py.user
Date 2015-06-13.06:47:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1434178022.79.0.230343884775.issue24444@psf.upfronthosting.co.za>
In-reply-to
Content
>>> 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.
History
Date User Action Args
2015-06-13 06:47:02py.usersetrecipients: + py.user
2015-06-13 06:47:02py.usersetmessageid: <1434178022.79.0.230343884775.issue24444@psf.upfronthosting.co.za>
2015-06-13 06:47:02py.userlinkissue24444 messages
2015-06-13 06:47:02py.usercreate