getScreenWidth() returns an invalid width of zero
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Smart Package Manager |
Fix Released
|
Undecided
|
Gustavo Niemeyer |
Bug Description
Smart versions: .52 and 1.1
Under a very specific condition, such as when using pexpect to spawn a smart process to do some work from turbo gears web server, smart fails to get a valid screen width when calling getScreenWidth(). In this environment it returns a value of zero which in turn creates problems later on by generating a badly formed self._topicmaskn inside interfaces/
the workaround is to change the following code from interface.py:
def getScreenWidth():
s = struct.pack('HHHH', 0, 0, 0, 0)
try:
x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
except IOError:
return 80
return struct.
to:
def getScreenWidth():
s = struct.pack('HHHH', 0, 0, 0, 0)
try:
x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
except IOError:
return 80
width = struct.
if width > 0:
return width
else:
return 80
which ensures returning a valid default value when the width is reported to be zero or less than zero.
Camilo
Related branches
- Smart Package Manager Team: Pending requested
Changed in smart: | |
milestone: | 1.2 → 1.1.2 |
This was also in openSUSE, as smart-0. 52-termios- 0width. patch:
* Sat Jan 26 2008 guru AT unixtech.be
- added patch to fix terminal width determination on serial and xen consoles