Skip to content

Commit e818202

Browse files
authoredSep 19, 2024
[clang] Fix python comparison to None (#94014)
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. Co-authored-by: Eisuke Kawashima <[email protected]>
1 parent 698be40 commit e818202

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed
 

‎clang/docs/DebuggingCoroutines.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
513513
self.coro_frame = coro_frame
514514
self.resume_func = dereference(self.coro_frame.resume_addr)
515515
self.resume_func_block = gdb.block_for_pc(self.resume_func)
516-
if self.resume_func_block == None:
516+
if self.resume_func_block is None:
517517
raise Exception('Not stackless coroutine.')
518518
self.line_info = gdb.find_pc_line(self.resume_func)
519519
@@ -543,8 +543,8 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
543543
self.function_name = f
544544
545545
def __str__(self, shift = 2):
546-
addr = "" if self.address() == None else '%#x' % self.address() + " in "
547-
location = "" if self.filename() == None else " at " + self.filename() + ":" + str(self.line())
546+
addr = "" if self.address() is None else '%#x' % self.address() + " in "
547+
location = "" if self.filename() is None else " at " + self.filename() + ":" + str(self.line())
548548
return addr + self.function() + " " + str([str(args) for args in self.frame_args()]) + location
549549
550550
class CoroutineFilter:
@@ -598,7 +598,7 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
598598
599599
addr = int(argv[0], 16)
600600
block = gdb.block_for_pc(long(cast_addr2long_pointer(addr).dereference()))
601-
if block == None:
601+
if block is None:
602602
print "block " + str(addr) + " is none."
603603
return
604604

‎clang/tools/include-mapping/gen_std.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def GetCCompatibilitySymbols(symbol):
215215
# Introduce two more entries, both in the global namespace, one using the
216216
# C++-compat header and another using the C header.
217217
results = []
218-
if symbol.namespace != None:
218+
if symbol.namespace is not None:
219219
# avoid printing duplicated entries, for C macros!
220220
results.append(cppreference_parser.Symbol(symbol.name, None, [header]))
221221
c_header = "<" + header[2:-1] + ".h>" # <cstdio> => <stdio.h>

‎clang/utils/check_cfc/obj_diff.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def first_diff(a, b, fromfile, tofile):
5757
first_diff_idx = idx
5858
break
5959

60-
if first_diff_idx == None:
60+
if first_diff_idx is None:
6161
# No difference
6262
return None
6363

‎clang/utils/module-deps-to-rsp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def main():
7474

7575
if args.module_name:
7676
cmd = findModule(args.module_name, full_deps)["command-line"]
77-
elif args.tu_index != None:
77+
elif args.tu_index is not None:
7878
tu = full_deps.translation_units[args.tu_index]
7979
cmd = tu["commands"][args.tu_cmd_index]["command-line"]
8080

0 commit comments

Comments
 (0)