mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-24444: fix an error in argparse help when help for an option is blank (GH-28050) (GH-28931)
(cherry picked from commit 6fafc25aea)
Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
This commit is contained in:
parent
f8473f6f76
commit
fd2be6da2f
3 changed files with 44 additions and 5 deletions
|
|
@ -526,12 +526,13 @@ def _format_action(self, action):
|
|||
parts = [action_header]
|
||||
|
||||
# if there was help for the action, add lines of help text
|
||||
if action.help:
|
||||
if action.help and action.help.strip():
|
||||
help_text = self._expand_help(action)
|
||||
help_lines = self._split_lines(help_text, help_width)
|
||||
parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
|
||||
for line in help_lines[1:]:
|
||||
parts.append('%*s%s\n' % (help_position, '', line))
|
||||
if help_text:
|
||||
help_lines = self._split_lines(help_text, help_width)
|
||||
parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
|
||||
for line in help_lines[1:]:
|
||||
parts.append('%*s%s\n' % (help_position, '', line))
|
||||
|
||||
# or add a newline if the description doesn't end with one
|
||||
elif not action_header.endswith('\n'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue