New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shutil.get_terminal_size() returns 0 when run in a pty #86340
Comments
When shutil.get_terminal_size() is used in a PTY, the os.get_terminal_size() call can return (0, 0). With the pty script from python/mypy#8144 (comment): $ python3 t.py python3 -c 'import shutil; print(shutil.get_terminal_size())'
os.terminal_size(columns=0, lines=0) While the following cases *are* handled by returning the fallback:
The case of os.get_terminal_size() succeeding but returning (0, 0) should probably be handled the same way as well. This e.g. affects mypy when run with pre-commit: |
Just found another workaround for this in the wild, as part of the "rich" library: https://github.com/willmcgugan/rich/blob/v9.1.0/rich/console.py#L669-L672 |
We decided not to backport this to 3.10 nor 3.9 due to the subtle nature of the change. |
Thanks for the fix, Filipe! ✨ 🍰 ✨ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: