netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Thomas Haller <thaller@redhat.com>
Cc: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [nft PATCH] py: return boolean value from Nftables.__[gs]et_output_flag()
Date: Wed, 19 Jul 2023 12:44:32 +0200	[thread overview]
Message-ID: <ZLe+kDS8ti84m2zu@orbyte.nwl.cc> (raw)
In-Reply-To: <20230718103325.277535-1-thaller@redhat.com>

On Tue, Jul 18, 2023 at 12:33:09PM +0200, Thomas Haller wrote:
> The callers of __get_output_flag() and __set_output_flag(), for example
> get_reversedns_output(), are all documented to return a "boolean" value.
> 
> Instead, they returned the underlying, non-zero flags value. That number
> is not obviously useful to the caller, because there is no API so that
> the caller could do anything with it (except evaluating it in a boolean
> context). Adjust that, to match the documentation.
> 
> The alternative would be to update the documentation, to indicate that
> the functions return a non-zero integer when the flag is set. That would
> preserve the previous behavior and maybe the number could be useful
> somehow(?).
> 
> Signed-off-by: Thomas Haller <thaller@redhat.com>

Patch applied, thanks!

I wasn't aware Python is not intuitive (from a C programmer's point of
view) in that regard:

| >>> 0 == True
| False
| >>> 1 == True
| True
| >>> 2 == True
| False
| >>> 3 == True
| False
| >>> if 3:
| ...   print("ok")
| ... 
| ok


      reply	other threads:[~2023-07-19 10:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 10:33 [nft PATCH] py: return boolean value from Nftables.__[gs]et_output_flag() Thomas Haller
2023-07-19 10:44 ` Phil Sutter [this message]

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=ZLe+kDS8ti84m2zu@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=thaller@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).