Skip to content
Snippets Groups Projects
Commit 80708959161a authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

scmutil: narrow ImportError handling in termwidth()

The array module must exist. It's sufficient to suppress the ImportError of
termios. Also salvaged the comment why we have to handle AttributeError, from
7002bb17cc5e.
parent 5c379b1f56c7
No related branches found
No related tags found
No related merge requests found
from __future__ import absolute_import
import array
import errno
import fcntl
import os
......@@ -43,5 +44,4 @@
def termwidth(ui):
try:
import array
import termios
......@@ -47,4 +47,8 @@
import termios
TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449)
except (AttributeError, ImportError):
return 80
if True:
for dev in (ui.ferr, ui.fout, ui.fin):
try:
try:
......@@ -53,8 +57,8 @@
continue
if not os.isatty(fd):
continue
try:
arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
if True:
arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8)
width = array.array('h', arri)[1]
if width > 0:
return width
......@@ -58,8 +62,6 @@
width = array.array('h', arri)[1]
if width > 0:
return width
except AttributeError:
pass
except ValueError:
pass
except IOError as e:
......@@ -67,6 +69,4 @@
pass
else:
raise
except ImportError:
pass
return 80
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment