[PATCH 6/9] Use "is" not "==" for None

From: Elisha Hollander
Date: Mon May 24 2021 - 11:31:44 EST


Using == is not always a good idea when dealing with None's, for example, if you have this class:
`class NotNone: __eq__ = lambda self, other: True`
Then NotNone()==None returns True
But NonNone() is None returns False

And PEP 8 says: "Comparisons to singletons like None should always be done with 'is' or 'is not', NEVER the equality operators."
---
tools/perf/scripts/python/compaction-times.py | 2 +-
tools/perf/scripts/python/mem-phys-addr.py | 2 +-
tools/perf/scripts/python/net_dropmonitor.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/scripts/python/compaction-times.py b/tools/perf/scripts/python/compaction-times.py
index 5822b552756d..83098803144b 100644
--- a/tools/perf/scripts/python/compaction-times.py
+++ b/tools/perf/scripts/python/compaction-times.py
@@ -30,7 +30,7 @@ class comm_filter:

def filter(self, pid, comm):
m = self.re.search(comm)
- return m == None or m.group() == ""
+ return m is None or m.group() == ""

class pid_filter:
def __init__(self, low, high):
diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
index 66b7ee8254c3..c6064ed7a231 100644
--- a/tools/perf/scripts/python/mem-phys-addr.py
+++ b/tools/perf/scripts/python/mem-phys-addr.py
@@ -94,6 +94,6 @@ def process_event(param_dict):
phys_addr = sample["phys_addr"]

global event_name
- if event_name == None:
+ if event_name is None:
event_name = name
load_mem_type_cnt[find_memory_type(phys_addr)] += 1
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py
index 101059971738..cd9488f11e03 100755
--- a/tools/perf/scripts/python/net_dropmonitor.py
+++ b/tools/perf/scripts/python/net_dropmonitor.py
@@ -55,7 +55,7 @@ def print_drop_table():
print("%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT"))
for i in drop_log.keys():
(sym, off) = get_sym(i)
- if sym == None:
+ if sym is None:
sym = i
print("%25s %25s %25s" % (sym, off, drop_log[i]))

--
2.25.1