public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Gal Pressman <gal@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>, <netdev@vger.kernel.org>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Joe Damato <joe@dama.to>, Stanislav Fomichev <sdf@fomichev.me>,
	<linux-kselftest@vger.kernel.org>, Nimrod Oren <noren@nvidia.com>
Subject: Re: [PATCH net] selftests: net: fix wrong boolean evaluation in __exit__
Date: Tue, 20 Jan 2026 15:44:13 -0800	[thread overview]
Message-ID: <20260120154413.6fe90947@kernel.org> (raw)
In-Reply-To: <20260120124733.604590-1-gal@nvidia.com>

On Tue, 20 Jan 2026 14:47:33 +0200 Gal Pressman 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.
> 
> 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.

Sure, the checkers complain about this, but I don't see an actual bug
here. bool(terminate) must evaluate correctly, we don't compare it
to True or False explicitly.

To be clear - the patch LGTM, I'm just not connecting the dots on why
its a fix at this stage.
-- 
pw-bot: cr

  reply	other threads:[~2026-01-20 23:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 12:47 [PATCH net] selftests: net: fix wrong boolean evaluation in __exit__ Gal Pressman
2026-01-20 23:44 ` Jakub Kicinski [this message]
2026-01-21  7:11   ` Gal Pressman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260120154413.6fe90947@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=joe@dama.to \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=noren@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox