Fix shutil.get_terminal_size() error handling

Issue #26801: Fix error handling in shutil.get_terminal_size(), catch
AttributeError instead of NameError. Patch written by Emanuel Barry.

test_shutil: skip the functional test using "stty size" command if
os.get_terminal_size() is missing.
This commit is contained in:
Victor Stinner 2016-04-19 22:24:56 +02:00
parent ded4c4967b
commit 119ebb70e9
4 changed files with 8 additions and 1 deletions

View file

@ -1069,7 +1069,7 @@ def get_terminal_size(fallback=(80, 24)):
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