knotty: Cast two variables to int in integer expressions
PATCH 1/1 knotty: Cast two variables to int in integer expressions
Python 3.14 complain 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'
Cast self.rows and self.columns to int.
--- lib/bb/ui/knotty.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/ui/knotty.py +2 -2
@@ -338,7 +338,7 @@ class TerminalFilter(object): print('', file=self._footer_buf) lines = self.getlines(content) if not self.quiet: - for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): + for tasknum, task in enumerate(tasks[:(int(self.rows) - 1 - lines)]): if isinstance(task, tuple): pbar, msg, progress, rate, start_time = task if not pbar.start_time:
@@ -367,7 +367,7 @@ class TerminalFilter(object): def getlines(self, content): lines = 0 for line in content.split("\n"): - lines = lines + 1 + int(len(line) / (self.columns + 1)) + lines = lines + 1 + int(len(line) / (int(self.columns) + 1)) return lines def finish(self):
Signature · 1 line
2.51.1
Quoted 61 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Zoltan Boszormenyi via lists.openembedded.org
Sent: den 5 november 2025 08:14
To: [email protected]
Cc: Zoltán Böszörményi <[email protected]>
Subject: [bitbake-devel] [PATCH] knotty: Cast two variables to int in integer expressionsPython 3.14 complain about these:
Traceback (most recent call last):
File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 722, in maintermfilter.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 maintermfilter.updateFooter() ~~~~~~~~~~~~~~~~~~~~~~~^^File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 341, in updateFooter
for tasknum, task inenumerate(tasks[:(self.rows - 1 - lines)]):
~~~~~~~~~~^~~
TypeError: unsupported operand type(s) for -: 'str' and 'int'Cast self.rows and self.columns to int.
Signed-off-by Zoltán Böszörményi <[email protected]>--- lib/bb/ui/knotty.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bb/ui/knotty.py +2
-3@@ -338,7 +338,7 @@ class TerminalFilter(object): print('', file=self._footer_buf) lines = self.getlines(content) if not self.quiet: - for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): + for tasknum, task in enumerate(tasks[:(int(self.rows) - 1 - lines)]): if isinstance(task, tuple): pbar, msg, progress, rate, start_time = task if not pbar.start_time:@@ -367,7 +367,7 @@ class TerminalFilter(object): def getlines(self, content): lines = 0 for line in content.split("\n"): - lines = lines + 1 + int(len(line) / (self.columns + 1)) + lines = lines + 1 + int(len(line) / (int(self.columns) + 1)) return lines def finish(self): --
Quoted 1 line
2.51.1
Wouldn't it make more sense to make getTerminalColumns() return two integers? If I understand the code correctly, this should only be a problem when reading the sizes from the environment, so changing this:
cr = (os.environ['LINES'], os.environ['COLUMNS'])
to this:
cr = (int(os.environ['LINES']), int(os.environ['COLUMNS']))
should solve the problem.
//Peter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 75 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Peter Kjellerstedt via lists.openembedded.org
Sent: den 5 november 2025 11:27
To: [email protected]; [email protected]
Subject: Re: [bitbake-devel] [PATCH] knotty: Cast two variables to int in integer expressionsQuoted 61 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Zoltan Boszormenyi via lists.openembedded.org
Sent: den 5 november 2025 08:14
To: [email protected]
Cc: Zoltán Böszörményi <[email protected]>
Subject: [bitbake-devel] [PATCH] knotty: Cast two variables to int in integer expressionsPython 3.14 complain about these:
Traceback (most recent call last):
File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 722, in maintermfilter.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 maintermfilter.updateFooter() ~~~~~~~~~~~~~~~~~~~~~~~^^File "/mnt2/zozo/yocto-5.3/bitbake/lib/bb/ui/knotty.py", line 341, in updateFooter
for tasknum, task inenumerate(tasks[:(self.rows - 1 - lines)]):
~~~~~~~~~~^~~
TypeError: unsupported operand type(s) for -: 'str' and 'int'Cast self.rows and self.columns to int.
Signed-off-by Zoltán Böszörményi <[email protected]>--- lib/bb/ui/knotty.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bb/ui/knotty.py +2
-3@@ -338,7 +338,7 @@ class TerminalFilter(object): print('', file=self._footer_buf) lines = self.getlines(content) if not self.quiet: - for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): + for tasknum, task in enumerate(tasks[:(int(self.rows) - 1 - lines)]): if isinstance(task, tuple): pbar, msg, progress, rate, start_time = task if not pbar.start_time:@@ -367,7 +367,7 @@ class TerminalFilter(object): def getlines(self, content): lines = 0 for line in content.split("\n"): - lines = lines + 1 + int(len(line) / (self.columns + 1)) + lines = lines + 1 + int(len(line) / (int(self.columns) + 1)) return lines def finish(self): --Quoted 1 line
2.51.1
Wouldn't it make more sense to make
getTerminalColumns()return two integers? If I understand the code correctly, this should only be a problem when reading the sizes from the environment, so changing this:cr = (os.environ['LINES'], os.environ['COLUMNS'])
Quoted 7 lines
to this:
cr = (int(os.environ['LINES']), int(os.environ['COLUMNS']))should solve the problem.
//Peter
Oh, and I would also change the subject to say:
knotty: Make sure getTerminalColumns() returns two integers
//Peter
2025. 11. 05. 11:32 keltezéssel, Peter Kjellerstedt írta:
Quoted 78 lines
Quoted 78 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Peter Kjellerstedt via lists.openembedded.org
Sent: den 5 november 2025 11:27
To: [email protected]; [email protected]
Subject: Re: [bitbake-devel] [PATCH] knotty: Cast two variables to int in integer expressionsQuoted 61 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Zoltan Boszormenyi via lists.openembedded.org
Sent: den 5 november 2025 08:14
To: [email protected]
Cc: Zoltán Böszörményi <[email protected]>
Subject: [bitbake-devel] [PATCH] knotty: Cast two variables to int in integer expressionsPython 3.14 complain 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'
Cast self.rows and self.columns to int.
Signed-off-by Zoltán Böszörményi <[email protected]>--- lib/bb/ui/knotty.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bb/ui/knotty.py +2
-3@@ -338,7 +338,7 @@ class TerminalFilter(object): print('', file=self._footer_buf) lines = self.getlines(content) if not self.quiet: - for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): + for tasknum, task in enumerate(tasks[:(int(self.rows) - 1 - lines)]): if isinstance(task, tuple): pbar, msg, progress, rate, start_time = task if not pbar.start_time:@@ -367,7 +367,7 @@ class TerminalFilter(object): def getlines(self, content): lines = 0 for line in content.split("\n"): - lines = lines + 1 + int(len(line) / (self.columns + 1)) + lines = lines + 1 + int(len(line) / (int(self.columns) + 1)) return lines def finish(self): --Quoted 1 line
2.51.1
Wouldn't it make more sense to make
getTerminalColumns()return two integers? If I understand the code correctly, this should only be a problem when reading the sizes from the environment, so changing this:cr = (os.environ['LINES'], os.environ['COLUMNS'])to this:
cr = (int(os.environ['LINES']), int(os.environ['COLUMNS']))
Quoted 8 lines
Quoted 3 lines
should solve the problem.
//Peter
Oh, and I would also change the subject to say:
knotty: Make sure
getTerminalColumns()returns two integers//Peter
Thanks for the suggestions, I will send a new patch.
FWIW, this change allows using Fedora 43 with Python 3.14.0 as the build host.