summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2018-07-25 15:23:44 (GMT)
committerGitHub <noreply@github.com>2018-07-25 15:23:44 (GMT)
commit74102c9a5f2327c4fc47feefa072854a53551d1f (patch)
treebc6ef255acbe46650c753977363c7c7c5e9d5c73 /Lib/argparse.py
parentc0f0a7669c73c0d444851dd4c5299de2479214cc (diff)
downloadcpython-74102c9a5f2327c4fc47feefa072854a53551d1f.zip
cpython-74102c9a5f2327c4fc47feefa072854a53551d1f.tar.gz
cpython-74102c9a5f2327c4fc47feefa072854a53551d1f.tar.bz2
bpo-13041: Use shutil.get_terminal_size() in argparse.HelpFormatter (GH-8459)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index a030749..83f47e3 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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