mirror of
https://github.com/python/cpython.git
synced 2025-12-10 02:50:09 +00:00
bpo-13041: Use shutil.get_terminal_size() in argparse.HelpFormatter (GH-8459)
This commit is contained in:
parent
c0f0a7669c
commit
74102c9a5f
3 changed files with 8 additions and 6 deletions
|
|
@ -85,6 +85,7 @@ __all__ = [
|
|||
|
||||
import os as _os
|
||||
import re as _re
|
||||
import shutil as _shutil
|
||||
import sys as _sys
|
||||
|
||||
from gettext import gettext as _, ngettext
|
||||
|
|
@ -164,10 +165,7 @@ class HelpFormatter(object):
|
|||
|
||||
# default setting for width
|
||||
if width is None:
|
||||
try:
|
||||
width = int(_os.environ['COLUMNS'])
|
||||
except (KeyError, ValueError):
|
||||
width = 80
|
||||
width = _shutil.get_terminal_size().columns
|
||||
width -= 2
|
||||
|
||||
self._prog = prog
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue