Skip to content

Commit 0e3b1cf

Browse files
r#2
1 parent 3f0780b commit 0e3b1cf

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

moler/io/raw/pty_process_unicode.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ def setwinsize(self, rows: int, cols: int) -> None:
8787
:return: None
8888
"""
8989
max_size = 65535
90-
if rows <= 0 or cols <= 0 or rows > max_size or cols > max_size:
90+
if rows < 1 or cols < 1 or rows > max_size or cols > max_size:
9191
raise ValueError(f"Terminal dimensions (rows={rows}, cols={cols}) must be between 1 and {max_size}, "
9292
"inclusive.")
9393
if self.fd < 0:
9494
raise MolerException("Cannot resize closed pty process")
9595

9696
try:
9797
termios.tcsetwinsize(self.fd, (rows, cols))
98-
except AttributeError:
99-
# Fallback for Python/platforms that do not expose tcsetwinsize(). Python < 3.11
98+
except (AttributeError, NotImplementedError):
99+
# New way of setting terminal dimensions failed. Try old way - Python < 3.11
100100
tiocswinsz = getattr(termios, "TIOCSWINSZ", None)
101101
if tiocswinsz is None:
102102
osname = platform.system()
@@ -111,8 +111,8 @@ def setwinsize(self, rows: int, cols: int) -> None:
111111
raise MolerException(f"Unsupported system: '{osname}' for setting terminal dimensions.")
112112
window_size = struct.pack("HHHH", rows, cols, 0, 0)
113113
fcntl.ioctl(self.fd, tiocswinsz, window_size)
114-
except NotImplementedError:
115-
raise MolerException(f"Platform: '{platform.system()}' does not support setting terminal dimensions.")
114+
except Exception as e:
115+
raise MolerException(f"Failed to set terminal dimensions: {e}") from e
116116
self.dimensions = (rows, cols)
117117

118118
def write(self, data: Union[str, bytes]) -> int:

0 commit comments

Comments
 (0)