linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vmbus_testing: fix wrong python syntax for integer value comparison
@ 2023-07-05 13:44 Ani Sinha
  2023-07-17  7:43 ` Ani Sinha
  0 siblings, 1 reply; 3+ messages in thread
From: Ani Sinha @ 2023-07-05 13:44 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui
  Cc: Ani Sinha, linux-hyperv, linux-kernel

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 "=="?

Signed-off-by: Ani Sinha <anisinha@redhat.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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmbus_testing: fix wrong python syntax for integer value comparison
  2023-07-05 13:44 [PATCH] vmbus_testing: fix wrong python syntax for integer value comparison Ani Sinha
@ 2023-07-17  7:43 ` Ani Sinha
  2023-07-23 23:19   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Ani Sinha @ 2023-07-17  7:43 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui
  Cc: linux-hyperv, linux-kernel



> On 05-Jul-2023, at 7:14 PM, Ani Sinha <anisinha@redhat.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@redhat.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
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmbus_testing: fix wrong python syntax for integer value comparison
  2023-07-17  7:43 ` Ani Sinha
@ 2023-07-23 23:19   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2023-07-23 23:19 UTC (permalink / raw)
  To: Ani Sinha
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	linux-hyperv, linux-kernel

On Mon, Jul 17, 2023 at 01:13:25PM +0530, Ani Sinha wrote:
> 
> 
> > On 05-Jul-2023, at 7:14 PM, Ani Sinha <anisinha@redhat.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 …
> 

Applied to hyperv-fixes. Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-23 23:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 13:44 [PATCH] vmbus_testing: fix wrong python syntax for integer value comparison Ani Sinha
2023-07-17  7:43 ` Ani Sinha
2023-07-23 23:19   ` Wei Liu

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).