Merge 3.5: issue #26801
diff --git a/Lib/shutil.py b/Lib/shutil.py
index f47a763..ca6c47f 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -1072,7 +1072,7 @@
if columns <= 0 or lines <= 0:
try:
size = os.get_terminal_size(sys.__stdout__.fileno())
- except (NameError, OSError):
+ except (AttributeError, OSError):
size = os.terminal_size(fallback)
if columns <= 0:
columns = size.columns
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index ca1d006..7e41891 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1837,6 +1837,8 @@
self.assertEqual(size.lines, 888)
@unittest.skipUnless(os.isatty(sys.__stdout__.fileno()), "not on tty")
+ @unittest.skipUnless(hasattr(os, 'get_terminal_size'),
+ 'need os.get_terminal_size()')
def test_stty_match(self):
"""Check if stty returns the same results ignoring env
diff --git a/Misc/ACKS b/Misc/ACKS
index c8e3cc5..615c473 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -90,6 +90,7 @@
Richard Barran
Cesar Eduardo Barros
Des Barry
+Emanuel Barry
Ulf Bartelt
Campbell Barton
Don Bashford
diff --git a/Misc/NEWS b/Misc/NEWS
index 473fb37..fba505f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -245,6 +245,10 @@
Library
-------
+- Issue #26801: Fix error handling in :func:`shutil.get_terminal_size`, catch
+ :exc:`AttributeError` instead of :exc:`NameError`. Patch written by Emanuel
+ Barry.
+
- Issue #24838: tarfile's ustar and gnu formats now correctly calculate name
and link field limits for multibyte character encodings like utf-8.