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>
.. versionadded:: 3.3
+ .. versionchanged:: 3.11
+ The ``fallback`` values are also used if :func:`os.get_terminal_size`
+ returns zeroes.
+
.. _`fcopyfile`:
http://www.manpagez.com/man/3/copyfile/
# 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))
--- /dev/null
+:meth:`shutil.get_terminal_size` now falls back to sane values if the column
+or line count are 0.