mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
bpo-42174: fallback to sane values if the columns or lines are 0 in get_terminal_size (GH-29046)
I considered only falling back when both were 0, but that still seems wrong, and the highly popular rich[1] library does it this way, so I thought we should probably inherit that behavior. [1] https://github.com/willmcgugan/rich Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
574241632b
commit
236e301b8a
3 changed files with 8 additions and 2 deletions
|
@ -1372,9 +1372,9 @@ def get_terminal_size(fallback=(80, 24)):
|
|||
# os.get_terminal_size() is unsupported
|
||||
size = os.terminal_size(fallback)
|
||||
if columns <= 0:
|
||||
columns = size.columns
|
||||
columns = size.columns or fallback[0]
|
||||
if lines <= 0:
|
||||
lines = size.lines
|
||||
lines = size.lines or fallback[1]
|
||||
|
||||
return os.terminal_size((columns, lines))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue