linux/tools/testing/selftests/net/lib/py
Gal Pressman a84a1fe0fb selftests: net: fix wrong boolean evaluation in __exit__
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>
Link: https://patch.msgid.link/20260125105524.773993-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-01-26 19:32:20 -08:00
..
__init__.py selftests: drv-net: Bring back tool() to driver __init__s 2026-01-06 17:52:08 -08:00
consts.py selftests: net: add scaffolding for Netlink tests in Python 2024-04-08 11:40:41 +01:00
ksft.py selftests: net: py: teach ksft_pr() multi-line safety 2026-01-13 17:54:00 -08:00
netns.py selftests: net: Add python context manager for netns entering 2025-02-21 15:28:03 -08:00
nsim.py selftests: net: py: read ip link info about remote dev 2025-11-20 18:19:29 -08:00
utils.py selftests: net: fix wrong boolean evaluation in __exit__ 2026-01-26 19:32:20 -08:00
ynl.py selftests: drv-net: base device access API test 2025-09-30 15:17:21 +02:00