diff mbox series

knotty: Make sure getTerminalColumns() returns two integers

Message ID 20251105105936.3698613-1-zboszor@gmail.com
State New
Headers show
Series knotty: Make sure getTerminalColumns() returns two integers | expand

Commit Message

Zoltán Böszörményi Nov. 5, 2025, 10:59 a.m. UTC
Python 3.14 complains about these:

Traceback (most recent call last):
  File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 722, in main
    termfilter.updateFooter()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 339, in updateFooter
    lines = self.getlines(content)
  File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 370, in getlines
    lines = lines + 1 + int(len(line) / (self.columns + 1))
                                         ~~~~~~~~~~~~~^~~
TypeError: can only concatenate str (not "int") to str

and

Traceback (most recent call last):
  File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 722, in main
    termfilter.updateFooter()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 341, in updateFooter
    for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]):
                                           ~~~~~~~~~~^~~
TypeError: unsupported operand type(s) for -: 'str' and 'int'

Make sure getting the number of rows and columns from the terminal
via the environment variables LINES and COLUMNS are returned as a
pair of integers. This matches the return value of ioctl_GWINSZ().

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
 lib/bb/ui/knotty.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 00258c80f..191731dda 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -157,7 +157,7 @@  class TerminalFilter(object):
                 pass
         if not cr:
             try:
-                cr = (os.environ['LINES'], os.environ['COLUMNS'])
+                cr = (int(os.environ['LINES']), int(os.environ['COLUMNS']))
             except:
                 cr = (25, 80)
         return cr