[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <761F02E9-7A80-486B-8CB4-B5E067D7F587@redhat.com>
Date: Mon, 17 Jul 2023 13:13:25 +0530
From: Ani Sinha <anisinha@...hat.com>
To: "K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>
Cc: linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vmbus_testing: fix wrong python syntax for integer value
comparison
> On 05-Jul-2023, at 7:14 PM, Ani Sinha <anisinha@...hat.com> wrote:
>
> It is incorrect in python to compare integer values using the "is" keyword.
> The "is" keyword in python is used to compare references to two objects,
> not their values. Newer version of python3 (version 3.8) throws a warning
> when such incorrect comparison is made. For value comparison, "==" should
> be used.
>
> Fix this in the code and suppress the following warning:
>
> /usr/sbin/vmbus_testing:167: SyntaxWarning: "is" with a literal. Did you mean "=="?
Ping …
>
> Signed-off-by: Ani Sinha <anisinha@...hat.com>
> ---
> tools/hv/vmbus_testing | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/hv/vmbus_testing b/tools/hv/vmbus_testing
> index e7212903dd1d..4467979d8f69 100755
> --- a/tools/hv/vmbus_testing
> +++ b/tools/hv/vmbus_testing
> @@ -164,7 +164,7 @@ def recursive_file_lookup(path, file_map):
> def get_all_devices_test_status(file_map):
>
> for device in file_map:
> - if (get_test_state(locate_state(device, file_map)) is 1):
> + if (get_test_state(locate_state(device, file_map)) == 1):
> print("Testing = ON for: {}"
> .format(device.split("/")[5]))
> else:
> @@ -203,7 +203,7 @@ def write_test_files(path, value):
> def set_test_state(state_path, state_value, quiet):
>
> write_test_files(state_path, state_value)
> - if (get_test_state(state_path) is 1):
> + if (get_test_state(state_path) == 1):
> if (not quiet):
> print("Testing = ON for device: {}"
> .format(state_path.split("/")[5]))
> --
> 2.39.1
>
Powered by blists - more mailing lists