Re: [nft PATCH] py: return boolean value from Nftables.__[gs]et_output_flag()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

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




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux