Skip to content

Commit c450df1

Browse files
committed
fix(python): fix comparison to None
1 parent 079fdef commit c450df1

File tree

50 files changed

+75
-75
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+75
-75
lines changed

clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_checkers(checkers_td, checkers_rst):
4747
parent_package_ = package["ParentPackage"]
4848
hidden = (checker["Hidden"] != 0) or (package["Hidden"] != 0)
4949

50-
while parent_package_ != None:
50+
while parent_package_ is not None:
5151
parent_package = table_entries[parent_package_["def"]]
5252
checker_package_prefix = (
5353
parent_package["PackageName"] + "." + checker_package_prefix

clang/docs/DebuggingCoroutines.rst

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

compiler-rt/test/asan/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def get_required_attr(config, attr_name):
1212
attr_value = getattr(config, attr_name, None)
13-
if attr_value == None:
13+
if attr_value is None:
1414
lit_config.fatal(
1515
"No attribute %r in test configuration! You may need to run "
1616
"tests from your build directory or add this attribute "

compiler-rt/test/builtins/Unit/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
def get_required_attr(config, attr_name):
2323
attr_value = getattr(config, attr_name, None)
24-
if attr_value == None:
24+
if attr_value is None:
2525
lit_config.fatal(
2626
"No attribute %r in test configuration! You may need to run "
2727
"tests from your build directory or add this attribute "

compiler-rt/test/ctx_profile/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def get_required_attr(config, attr_name):
1515
attr_value = getattr(config, attr_name, None)
16-
if attr_value == None:
16+
if attr_value is None:
1717
lit_config.fatal(
1818
"No attribute %r in test configuration! You may need to run "
1919
"tests from your build directory or add this attribute "

compiler-rt/test/lsan/lit.common.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def get_required_attr(config, attr_name):
1212
attr_value = getattr(config, attr_name, None)
13-
if attr_value == None:
13+
if attr_value is None:
1414
lit_config.fatal(
1515
"No attribute %r in test configuration! You may need to run "
1616
"tests from your build directory or add this attribute "

compiler-rt/test/memprof/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def get_required_attr(config, attr_name):
1111
attr_value = getattr(config, attr_name, None)
12-
if attr_value == None:
12+
if attr_value is None:
1313
lit_config.fatal(
1414
"No attribute %r in test configuration! You may need to run "
1515
"tests from your build directory or add this attribute "

compiler-rt/test/profile/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def get_required_attr(config, attr_name):
88
attr_value = getattr(config, attr_name, None)
9-
if attr_value == None:
9+
if attr_value is None:
1010
lit_config.fatal(
1111
"No attribute %r in test configuration! You may need to run "
1212
"tests from your build directory or add this attribute "

compiler-rt/test/sanitizer_common/android_commands/android_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
elif arg == "-o":
2121
output = args.pop(0)
2222

23-
if output == None:
23+
if output is None:
2424
print("No output file name!")
2525
sys.exit(1)
2626

compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
elif arg == "-o":
2020
output = args.pop(0)
2121

22-
if output == None:
22+
if output is None:
2323
print("No output file name!")
2424
sys.exit(1)
2525

compiler-rt/test/ubsan/lit.common.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def get_required_attr(config, attr_name):
77
attr_value = getattr(config, attr_name, None)
8-
if attr_value == None:
8+
if attr_value is None:
99
lit_config.fatal(
1010
"No attribute %r in test configuration! You may need to run "
1111
"tests from your build directory or add this attribute "

compiler-rt/test/ubsan_minimal/lit.common.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def get_required_attr(config, attr_name):
77
attr_value = getattr(config, attr_name, None)
8-
if attr_value == None:
8+
if attr_value is None:
99
lit_config.fatal(
1010
"No attribute %r in test configuration! You may need to run "
1111
"tests from your build directory or add this attribute "

cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _build_command(
9898

9999
def label_to_line(label_name: str) -> int:
100100
line = labels.get(label_name, None)
101-
if line != None:
101+
if line is not None:
102102
return line
103103
raise format_unresolved_label_err(label_name, raw_text, path.base, lineno)
104104

cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
self.finish_on_remove = finish_on_remove
6363

6464
def has_conditions(self):
65-
return self.expression != None
65+
return self.expression is not None
6666

6767
def get_conditional_expression_list(self):
6868
conditional_list = []
@@ -76,7 +76,7 @@ def add_hit(self):
7676
self.current_hit_count += 1
7777

7878
def should_be_removed(self):
79-
if self.max_hit_count == None:
79+
if self.max_hit_count is None:
8080
return False
8181
return self.current_hit_count >= self.max_hit_count
8282

cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def update_step_watches(step_info, watches, commands):
3939
for watch in towatch:
4040
loc = step_info.current_location
4141
if (
42-
loc.path != None
42+
loc.path is not None
4343
and os.path.exists(loc.path)
4444
and os.path.samefile(watch.path, loc.path)
4545
and have_hit_line(watch, loc)

cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def handle_debugger_tool_options(context, defaults): # noqa
183183
if options.debugger == "lldb":
184184
_warn_meaningless_option(context, "--show-debugger")
185185

186-
if options.source_root_dir != None:
186+
if options.source_root_dir is not None:
187187
if not os.path.isabs(options.source_root_dir):
188188
raise ToolArgumentError(
189189
f'<d>--source-root-dir: expected absolute path, got</> <r>"{options.source_root_dir}"</>'

cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def delete_breakpoints(self, ids):
235235
for bp in self._debugger.Breakpoints:
236236
# We're looking at the user-set breakpoints so there should be no
237237
# Parent.
238-
assert bp.Parent == None
238+
assert bp.Parent is None
239239
this_vsbp = VSBreakpoint(
240240
PurePath(bp.File), bp.FileLine, bp.FileColumn, bp.Condition
241241
)

cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _get_results_path(self, test_name):
150150
"""Returns the path to the test results directory for the test denoted
151151
by test_name.
152152
"""
153-
assert self.context.options.results_directory != None
153+
assert self.context.options.results_directory is not None
154154
return os.path.join(
155155
self.context.options.results_directory,
156156
self._get_results_basename(test_name),

cross-project-tests/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
def get_required_attr(config, attr_name):
5656
attr_value = getattr(config, attr_name, None)
57-
if attr_value == None:
57+
if attr_value is None:
5858
lit_config.fatal(
5959
"No attribute %r in test configuration! You may need to run "
6060
"tests from your build directory or add this attribute "

lldb/docs/use/python.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ later explanations:
7575
12: if root_word == word:
7676
13: return cur_path
7777
14: elif word < root_word:
78-
15: if left_child_ptr.GetValue() == None:
78+
15: if left_child_ptr.GetValue() is None:
7979
16: return ""
8080
17: else:
8181
18: cur_path = cur_path + "L"
8282
19: return DFS (left_child_ptr, word, cur_path)
8383
20: else:
84-
21: if right_child_ptr.GetValue() == None:
84+
21: if right_child_ptr.GetValue() is None:
8585
22: return ""
8686
23: else:
8787
24: cur_path = cur_path + "R"

lldb/examples/python/armv7_cortex_m_target_defintion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def get_reg_num(reg_num_dict, reg_name):
222222

223223
def get_target_definition():
224224
global g_target_definition
225-
if g_target_definition == None:
225+
if g_target_definition is None:
226226
g_target_definition = {}
227227
offset = 0
228228
for reg_info in armv7_register_infos:

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
def is_exe(fpath):
4949
"""Returns true if fpath is an executable."""
50-
if fpath == None:
50+
if fpath is None:
5151
return False
5252
if sys.platform == "win32":
5353
if not fpath.endswith(".exe"):

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def pointer_size():
229229

230230
def is_exe(fpath):
231231
"""Returns true if fpath is an executable."""
232-
if fpath == None:
232+
if fpath is None:
233233
return False
234234
if sys.platform == "win32":
235235
if not fpath.endswith(".exe"):
@@ -2191,7 +2191,7 @@ def complete_from_to(self, str_input, patterns):
21912191
if num_matches == 0:
21922192
compare_string = str_input
21932193
else:
2194-
if common_match != None and len(common_match) > 0:
2194+
if common_match is not None and len(common_match) > 0:
21952195
compare_string = str_input + common_match
21962196
else:
21972197
compare_string = ""
@@ -2552,7 +2552,7 @@ def assertFailure(self, obj, error_str=None, msg=None):
25522552
if obj.Success():
25532553
self.fail(self._formatMessage(msg, "Error not in a fail state"))
25542554

2555-
if error_str == None:
2555+
if error_str is None:
25562556
return
25572557

25582558
error = obj.GetCString()

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,11 +1594,11 @@ def set_actions_for_signal(
15941594
):
15951595
return_obj = lldb.SBCommandReturnObject()
15961596
command = "process handle {0}".format(signal_name)
1597-
if pass_action != None:
1597+
if pass_action is not None:
15981598
command += " -p {0}".format(pass_action)
1599-
if stop_action != None:
1599+
if stop_action is not None:
16001600
command += " -s {0}".format(stop_action)
1601-
if notify_action != None:
1601+
if notify_action is not None:
16021602
command += " -n {0}".format(notify_action)
16031603

16041604
testcase.dbg.GetCommandInterpreter().HandleCommand(command, return_obj)

lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def traceStartProcess(
134134
self.assertSBError(trace.Start(configuration), error=error)
135135
else:
136136
command = "process trace start"
137-
if processBufferSizeLimit != None:
137+
if processBufferSizeLimit is not None:
138138
command += " -l " + str(processBufferSizeLimit)
139139
if enableTsc:
140140
command += " --tsc"

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def address_breakpoints(self):
3232
for region_idx in range(regions.GetSize()):
3333
region = lldb.SBMemoryRegionInfo()
3434
regions.GetMemoryRegionAtIndex(region_idx, region)
35-
if illegal_address == None or region.GetRegionEnd() > illegal_address:
35+
if illegal_address is None or region.GetRegionEnd() > illegal_address:
3636
illegal_address = region.GetRegionEnd()
3737

3838
if illegal_address is not None:

lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def run_step(self, stop_others_value, run_mode, token):
126126
cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s" % (
127127
token
128128
)
129-
if run_mode != None:
129+
if run_mode is not None:
130130
cmd = cmd + " --run-mode %s" % (run_mode)
131131
if self.TraceOn():
132132
print(cmd)

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def do_test(self, bkpt_modifier=None):
9999
backstop_bkpt_2.GetNumLocations(), 0, "Set our third breakpoint"
100100
)
101101

102-
if bkpt_modifier == None:
102+
if bkpt_modifier is None:
103103
process.Continue()
104104
self.assertState(
105105
process.GetState(), lldb.eStateStopped, "We didn't stop for the load"

lldb/test/API/lua_api/TestLuaAPI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def killProcess():
115115
out, err = p.communicate(input=input)
116116
exitCode = p.wait()
117117
finally:
118-
if timerObject != None:
118+
if timerObject is not None:
119119
timerObject.cancel()
120120

121121
# Ensure the resulting output is always of string type.

lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def suspended_thread_test(self):
9292
thread = lldb.SBThread()
9393
for thread in process.threads:
9494
th_name = thread.GetName()
95-
if th_name == None:
95+
if th_name is None:
9696
continue
9797
if "Look for me" in th_name:
9898
break

lldb/test/API/python_api/event/TestEvents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def wait_for_next_event(self, expected_state, test_shadow=False):
335335
if state == lldb.eStateStopped:
336336
restart = lldb.SBProcess.GetRestartedFromEvent(event)
337337

338-
if expected_state != None:
338+
if expected_state is not None:
339339
self.assertEqual(
340340
state, expected_state, "Primary thread got the correct event"
341341
)

lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ def test_read_memory_c_string(self):
6161
invalid_memory_str_addr, 2048, err
6262
)
6363
self.assertTrue(err.Fail())
64-
self.assertTrue(invalid_memory_string == "" or invalid_memory_string == None)
64+
self.assertTrue(invalid_memory_string == "" or invalid_memory_string is None)

lldb/test/API/python_api/type/TestTypeList.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test(self):
132132
"my_type_is_named has a named type",
133133
)
134134
self.assertTrue(field.type.IsAggregateType())
135-
elif field.name == None:
135+
elif field.name is None:
136136
self.assertTrue(
137137
field.type.IsAnonymousType(), "Nameless type is not anonymous"
138138
)

lldb/test/API/python_api/was_interrupted/interruptible.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __call__(self, debugger, args, exe_ctx, result):
4545
For the "check" case, it doesn't wait, but just returns whether there was
4646
an interrupt in force or not."""
4747

48-
if local_data == None:
48+
if local_data is None:
4949
result.SetError("local data was not set.")
5050
result.SetStatus(lldb.eReturnStatusFailed)
5151
return

lldb/test/Shell/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def calculate_arch_features(arch_string):
145145
if config.lldb_enable_lzma:
146146
config.available_features.add("lzma")
147147

148-
if shutil.which("xz") != None:
148+
if shutil.which("xz") is not None:
149149
config.available_features.add("xz")
150150

151151
if config.lldb_system_debugserver:

0 commit comments

Comments
 (0)