mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +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:
commit
18a8affc8e
2 changed files with 32 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue