summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-04-24 06:58:43 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-04-24 06:58:43 (GMT)
commitd30829def2be7edc649f06d73fdc5a4813e29d1f (patch)
tree50ee974b26294a8159185b50fd9239f22418e88b /Lib/shutil.py
parente37fc18b3c0d5fe13d75f37d9ae9c4387a46ee3d (diff)
downloadcpython-d30829def2be7edc649f06d73fdc5a4813e29d1f.zip
cpython-d30829def2be7edc649f06d73fdc5a4813e29d1f.tar.gz
cpython-d30829def2be7edc649f06d73fdc5a4813e29d1f.tar.bz2
Issue #26801: shutil.get_terminal_size() now handles the case of stdout is
reopened on Windows. Added tests for fallbacks.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 7f8edf5..37124a0 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -1069,7 +1069,9 @@ def get_terminal_size(fallback=(80, 24)):
if columns <= 0 or lines <= 0:
try:
size = os.get_terminal_size(sys.__stdout__.fileno())
- except (AttributeError, OSError):
+ except (AttributeError, ValueError, OSError):
+ # stdout is None, closed, detached, or not a terminal, or
+ # os.get_terminal_size() is unsupported
size = os.terminal_size(fallback)
if columns <= 0:
columns = size.columns