Skip to content
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

Fixed ZeroDivisionError in async_alert() when shutil.get_terminal_size().columns returned 0. #1374

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

kmvanbrunt
Copy link
Member

No description provided.

tleonhardt
tleonhardt previously approved these changes Nov 6, 2024
cmd2/cmd2.py Outdated
@@ -5335,9 +5335,12 @@ def async_alert(self, alert_msg: str, new_prompt: Optional[str] = None) -> None:
if update_terminal:
import shutil

# Prior to Python 3.11, this can return 0 for things like pseudo terminals.
terminal_columns = shutil.get_terminal_size().columns or 80
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I never considered the possibility of a zero-width terminal, but a guys for a pty that might be semi-reasonable.

nit: Consider defining a single constant for something like DEFAULT_TERMINAL_WIDTH = 80

@kmvanbrunt kmvanbrunt merged commit 2849002 into master Nov 6, 2024
46 checks passed
@kmvanbrunt kmvanbrunt deleted the zero_terminal_width branch November 6, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants