mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
Issue #26801: shutil.get_terminal_size() now handles the case of stdout is
reopened on Windows. Added tests for fallbacks.
This commit is contained in:
parent
e37fc18b3c
commit
d30829def2
2 changed files with 32 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue