* [PATCH net-next v2] selftests: net: fix wrong boolean evaluation in __exit__
@ 2026-01-25 10:55 Gal Pressman
2026-01-27 3:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Gal Pressman @ 2026-01-25 10:55 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, netdev
Cc: Simon Horman, Shuah Khan, Joe Damato, Stanislav Fomichev,
linux-kselftest, Gal Pressman, Nimrod Oren
The __exit__ method receives ex_type as the exception class when an
exception occurs. The previous code used implicit boolean evaluation:
terminate = self.terminate or (self._exit_wait and ex_type)
^^^^^^^^^^^
In Python, the and operator can be used with non-boolean values, but it
does not always return a boolean result.
This is probably not what we want, because 'self._exit_wait and ex_type'
could return the actual ex_type value (the exception class) rather than
a boolean True when an exception occurs.
Use explicit `ex_type is not None` check to properly evaluate whether
an exception occurred, returning a boolean result.
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
Changelog -
v1->v2: https://lore.kernel.org/all/20260120124733.604590-1-gal@nvidia.com/
* Target net-next and remove Fixes (Jakub).
---
tools/testing/selftests/net/lib/py/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index 106ee1f2df86..dc1db78b5304 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -137,7 +137,7 @@ class bkg(cmd):
def __exit__(self, ex_type, ex_value, ex_tb):
# Force termination on exception
- terminate = self.terminate or (self._exit_wait and ex_type)
+ terminate = self.terminate or (self._exit_wait and ex_type is not None)
return self.process(terminate=terminate, fail=self.check_fail)
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next v2] selftests: net: fix wrong boolean evaluation in __exit__
2026-01-25 10:55 [PATCH net-next v2] selftests: net: fix wrong boolean evaluation in __exit__ Gal Pressman
@ 2026-01-27 3:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-27 3:40 UTC (permalink / raw)
To: Gal Pressman
Cc: davem, edumazet, kuba, pabeni, andrew+netdev, netdev, horms,
shuah, joe, sdf, linux-kselftest, noren
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 25 Jan 2026 12:55:24 +0200 you wrote:
> The __exit__ method receives ex_type as the exception class when an
> exception occurs. The previous code used implicit boolean evaluation:
>
> terminate = self.terminate or (self._exit_wait and ex_type)
> ^^^^^^^^^^^
>
> In Python, the and operator can be used with non-boolean values, but it
> does not always return a boolean result.
>
> [...]
Here is the summary with links:
- [net-next,v2] selftests: net: fix wrong boolean evaluation in __exit__
https://git.kernel.org/netdev/net-next/c/a84a1fe0fb2e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-27 3:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-25 10:55 [PATCH net-next v2] selftests: net: fix wrong boolean evaluation in __exit__ Gal Pressman
2026-01-27 3:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox