diff --git a/Lib/argparse.py b/Lib/argparse.py --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -166,6 +166,7 @@ self._indent_increment = indent_increment self._max_help_position = max_help_position self._width = width + self._min_help_width = 10 self._current_indent = 0 self._level = 0 @@ -484,7 +485,7 @@ # determine the required width and the entry label help_position = min(self._action_max_length + 2, self._max_help_position) - help_width = self._width - help_position + help_width = max(self._width - help_position, self._min_help_width) action_width = help_position - self._current_indent - 2 action_header = self._format_action_invocation(action) diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -4754,6 +4754,18 @@ def test_nargs_3_metavar_length3(self): self.do_test_no_exception(nargs=3, metavar=("1", "2", "3")) +# ============= +# COLUMNS tests +# ============= + +class TestColumns(TestCase): + + def test_columns_1(self): + """Make sure that there are no exceptions for low COLUMNS value""" + with support.EnvironmentVarGuard() as env: + env.set('COLUMNS', '1') + argparse.ArgumentParser().print_help() + # ============================ # from argparse import * tests # ============================