Skip to content

Commit df63da0

Browse files
committed
ioctl can raise OSError
1 parent 48ae6c2 commit df63da0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/_pyrepl/unix_console.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ def getheightwidth(self):
450450
try:
451451
return int(os.environ["LINES"]), int(os.environ["COLUMNS"])
452452
except (KeyError, TypeError, ValueError):
453-
height, width = struct.unpack(
454-
"hhhh", ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8)
455-
)[0:2]
453+
try:
454+
size = ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8)
455+
except OSError:
456+
return 25, 80
457+
height, width = struct.unpack("hhhh", size)[0:2]
456458
if not height:
457459
return 25, 80
458460
return height, width

0 commit comments

Comments
 (0)