# HG changeset patch # User Zbigniew Jędrzejewski-Szmek # Date 1325854810 -3600 # Branch argparse-columns # Node ID 797266c867112f60dfa7a1f986ffc491ffb02599 # Parent 838a55436608019d5978b255c5b5f77a4308eaee Use os.get_terminal_size() to query terminal width This closes #13041. diff --git a/Lib/argparse.py b/Lib/argparse.py --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -156,11 +156,7 @@ # default setting for width if width is None: - try: - width = int(_os.environ['COLUMNS']) - except (KeyError, ValueError): - width = 80 - width -= 2 + width = _os.get_terminal_size().columns - 2 self._prog = prog self._indent_increment = indent_increment