[polly] fix(polly/**.py): fix comparison to None (PR #94021)
Eisuke Kawashima via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 25 11:58:42 PST 2024
https://github.com/e-kwsm updated https://github.com/llvm/llvm-project/pull/94021
>From e858460c99ff18326fa80288442a8a990a520d2c Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima <e-kwsm at users.noreply.github.com>
Date: Sat, 11 May 2024 23:57:11 +0900
Subject: [PATCH] fix(polly/**.py): fix comparison to None
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):
> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
polly/lib/External/isl/interface/python.cc | 2 +-
polly/lib/External/isl/libisl-gdb.py | 4 ++--
polly/lib/External/isl/python/isl.py.top | 4 ++--
polly/test/lit.site.cfg.in | 2 +-
polly/utils/pyscop/isl.py | 8 ++++----
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/polly/lib/External/isl/interface/python.cc b/polly/lib/External/isl/interface/python.cc
index e4a8288631297a..b60bf315ca7034 100644
--- a/polly/lib/External/isl/interface/python.cc
+++ b/polly/lib/External/isl/interface/python.cc
@@ -347,7 +347,7 @@ static void print_persistent_callback_failure_check(int indent,
printf(fmt, 0);
printf(", '%s') and ", callback_name.c_str());
printf(fmt, 0);
- printf(".%s['exc_info'] != None:\n", callback_name.c_str());
+ printf(".%s['exc_info'] is not None:\n", callback_name.c_str());
print_indent(indent, " exc_info = ");
printf(fmt, 0);
printf(".%s['exc_info'][0]\n", callback_name.c_str());
diff --git a/polly/lib/External/isl/libisl-gdb.py b/polly/lib/External/isl/libisl-gdb.py
index bf01bc583d15d8..bdd3949cf89c06 100644
--- a/polly/lib/External/isl/libisl-gdb.py
+++ b/polly/lib/External/isl/libisl-gdb.py
@@ -70,7 +70,7 @@ def invoke(self, arg, from_tty):
arg = gdb.parse_and_eval(arg)
printer = str_lookup_function(arg)
- if printer == None:
+ if printer is None:
print("No isl printer for this type")
return
@@ -90,7 +90,7 @@ def str_lookup_function(val):
lookup_tag = val.type.target()
regex = re.compile("^isl_(.*)$")
- if lookup_tag == None:
+ if lookup_tag is None:
return None
m = regex.match(str(lookup_tag))
diff --git a/polly/lib/External/isl/python/isl.py.top b/polly/lib/External/isl/python/isl.py.top
index d041315d4e11db..9dc47a1a832514 100644
--- a/polly/lib/External/isl/python/isl.py.top
+++ b/polly/lib/External/isl/python/isl.py.top
@@ -3,7 +3,7 @@ from ctypes import *
from ctypes.util import find_library
isl_dyld_library_path = os.environ.get('ISL_DYLD_LIBRARY_PATH')
-if isl_dyld_library_path != None:
+if isl_dyld_library_path is not None:
os.environ['DYLD_LIBRARY_PATH'] = isl_dyld_library_path
try:
isl = cdll.LoadLibrary(isl_dlname)
@@ -29,7 +29,7 @@ class Context:
@staticmethod
def getDefaultInstance():
- if Context.defaultInstance == None:
+ if Context.defaultInstance is None:
Context.defaultInstance = Context()
return Context.defaultInstance
diff --git a/polly/test/lit.site.cfg.in b/polly/test/lit.site.cfg.in
index d8a0b6ae3a3b2f..f22063e796deff 100644
--- a/polly/test/lit.site.cfg.in
+++ b/polly/test/lit.site.cfg.in
@@ -14,7 +14,7 @@ config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
## Check the current platform with regex
import re
EAT_ERR_ON_X86 = ' '
-if (re.match(r'^x86_64*', '@LLVM_TARGET_TRIPLE@') == None) :
+if (re.match(r'^x86_64*', '@LLVM_TARGET_TRIPLE@') is None) :
EAT_ERR_ON_X86 = '|| echo \"error is eaten\"'
for arch in config.targets_to_build.split():
diff --git a/polly/utils/pyscop/isl.py b/polly/utils/pyscop/isl.py
index 5eaf7798e20b97..c06b7bca28042b 100644
--- a/polly/utils/pyscop/isl.py
+++ b/polly/utils/pyscop/isl.py
@@ -24,7 +24,7 @@ def from_ptr(ptr):
@staticmethod
def getDefaultInstance():
- if Context.defaultInstance == None:
+ if Context.defaultInstance is None:
Context.defaultInstance = Context()
return Context.defaultInstance
@@ -33,12 +33,12 @@ def getDefaultInstance():
class IslObject:
def __init__(self, string="", ctx=None, ptr=None):
self.initialize_isl_methods()
- if ptr != None:
+ if ptr is not None:
self.ptr = ptr
self.ctx = self.get_isl_method("get_ctx")(self)
return
- if ctx == None:
+ if ctx is None:
ctx = Context.getDefaultInstance()
self.ctx = ctx
@@ -236,7 +236,7 @@ class Printer:
FORMAT_EXT_POLYLIB = 6
def __init__(self, ctx=None):
- if ctx == None:
+ if ctx is None:
ctx = Context.getDefaultInstance()
self.ctx = ctx
More information about the llvm-commits
mailing list