summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-04-24 06:59:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-04-24 06:59:17 (GMT)
commit18a8affc8ed282dca01155adc7a085bcc66be4ee (patch)
treebc2cb81046d0d86b9e9c2c0f9347a290e56367f0 /Lib/shutil.py
parenta497774b719a3bb61ea907eb2dfe0b435e61e24a (diff)
parentd30829def2be7edc649f06d73fdc5a4813e29d1f (diff)
downloadcpython-18a8affc8ed282dca01155adc7a085bcc66be4ee.zip
cpython-18a8affc8ed282dca01155adc7a085bcc66be4ee.tar.gz
cpython-18a8affc8ed282dca01155adc7a085bcc66be4ee.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 ca6c47f..b1953cc 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -1072,7 +1072,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