Skip to content

[lldb] fix(lldb/**.py): fix comparison to None #94017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/bindings/interface/SBBreakpointDocstrings.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TestBreakpointIgnoreCount.py),::
#lldbutil.print_stacktraces(process)
from lldbutil import get_stopped_thread
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
self.assertTrue(thread is not None, 'There should be a thread stopped due to breakpoint')
frame0 = thread.GetFrameAtIndex(0)
frame1 = thread.GetFrameAtIndex(1)
frame2 = thread.GetFrameAtIndex(2)
Expand Down
8 changes: 4 additions & 4 deletions lldb/bindings/interface/SBDataExtensions.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ STRING_EXTENSION_OUTSIDE(SBData)
lldbtarget = lldbdict['target']
else:
lldbtarget = None
if target == None and lldbtarget != None and lldbtarget.IsValid():
if target is None and lldbtarget is not None and lldbtarget.IsValid():
target = lldbtarget
if ptr_size == None:
if ptr_size is None:
if target and target.IsValid():
ptr_size = target.addr_size
else:
ptr_size = 8
if endian == None:
if endian is None:
if target and target.IsValid():
endian = target.byte_order
else:
endian = lldbdict['eByteOrderLittle']
if size == None:
if size is None:
if value > 2147483647:
size = 8
elif value < -2147483648:
Expand Down
4 changes: 2 additions & 2 deletions lldb/docs/use/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ later explanations:
12: if root_word == word:
13: return cur_path
14: elif word < root_word:
15: if left_child_ptr.GetValue() == None:
15: if left_child_ptr.GetValue() is None:
16: return ""
17: else:
18: cur_path = cur_path + "L"
19: return DFS (left_child_ptr, word, cur_path)
20: else:
21: if right_child_ptr.GetValue() == None:
21: if right_child_ptr.GetValue() is None:
22: return ""
23: else:
24: cur_path = cur_path + "R"
Expand Down
2 changes: 1 addition & 1 deletion lldb/examples/python/armv7_cortex_m_target_defintion.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def get_reg_num(reg_num_dict, reg_name):

def get_target_definition():
global g_target_definition
if g_target_definition == None:
if g_target_definition is None:
g_target_definition = {}
offset = 0
for reg_info in armv7_register_infos:
Expand Down
2 changes: 1 addition & 1 deletion lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

def is_exe(fpath):
"""Returns true if fpath is an executable."""
if fpath == None:
if fpath is None:
return False
if sys.platform == "win32":
if not fpath.endswith(".exe"):
Expand Down
6 changes: 3 additions & 3 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def pointer_size():

def is_exe(fpath):
"""Returns true if fpath is an executable."""
if fpath == None:
if fpath is None:
return False
if sys.platform == "win32":
if not fpath.endswith(".exe"):
Expand Down Expand Up @@ -2191,7 +2191,7 @@ def complete_from_to(self, str_input, patterns):
if num_matches == 0:
compare_string = str_input
else:
if common_match != None and len(common_match) > 0:
if common_match is not None and len(common_match) > 0:
compare_string = str_input + common_match
else:
compare_string = ""
Expand Down Expand Up @@ -2552,7 +2552,7 @@ def assertFailure(self, obj, error_str=None, msg=None):
if obj.Success():
self.fail(self._formatMessage(msg, "Error not in a fail state"))

if error_str == None:
if error_str is None:
return

error = obj.GetCString()
Expand Down
6 changes: 3 additions & 3 deletions lldb/packages/Python/lldbsuite/test/lldbutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,11 +1594,11 @@ def set_actions_for_signal(
):
return_obj = lldb.SBCommandReturnObject()
command = "process handle {0}".format(signal_name)
if pass_action != None:
if pass_action is not None:
command += " -p {0}".format(pass_action)
if stop_action != None:
if stop_action is not None:
command += " -s {0}".format(stop_action)
if notify_action != None:
if notify_action is not None:
command += " -n {0}".format(notify_action)

testcase.dbg.GetCommandInterpreter().HandleCommand(command, return_obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def traceStartProcess(
self.assertSBError(trace.Start(configuration), error=error)
else:
command = "process trace start"
if processBufferSizeLimit != None:
if processBufferSizeLimit is not None:
command += " -l " + str(processBufferSizeLimit)
if enableTsc:
command += " --tsc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def address_breakpoints(self):
for region_idx in range(regions.GetSize()):
region = lldb.SBMemoryRegionInfo()
regions.GetMemoryRegionAtIndex(region_idx, region)
if illegal_address == None or region.GetRegionEnd() > illegal_address:
if illegal_address is None or region.GetRegionEnd() > illegal_address:
illegal_address = region.GetRegionEnd()

if illegal_address is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def run_step(self, stop_others_value, run_mode, token):
cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s" % (
token
)
if run_mode != None:
if run_mode is not None:
cmd = cmd + " --run-mode %s" % (run_mode)
if self.TraceOn():
print(cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def do_test(self, bkpt_modifier=None):
backstop_bkpt_2.GetNumLocations(), 0, "Set our third breakpoint"
)

if bkpt_modifier == None:
if bkpt_modifier is None:
process.Continue()
self.assertState(
process.GetState(), lldb.eStateStopped, "We didn't stop for the load"
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/lua_api/TestLuaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def killProcess():
out, err = p.communicate(input=input)
exitCode = p.wait()
finally:
if timerObject != None:
if timerObject is not None:
timerObject.cancel()

# Ensure the resulting output is always of string type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def suspended_thread_test(self):
thread = lldb.SBThread()
for thread in process.threads:
th_name = thread.GetName()
if th_name == None:
if th_name is None:
continue
if "Look for me" in th_name:
break
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/python_api/event/TestEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def wait_for_next_event(self, expected_state, test_shadow=False):
if state == lldb.eStateStopped:
restart = lldb.SBProcess.GetRestartedFromEvent(event)

if expected_state != None:
if expected_state is not None:
self.assertEqual(
state, expected_state, "Primary thread got the correct event"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def test_read_memory_c_string(self):
invalid_memory_str_addr, 2048, err
)
self.assertTrue(err.Fail())
self.assertTrue(invalid_memory_string == "" or invalid_memory_string == None)
self.assertTrue(invalid_memory_string == "" or invalid_memory_string is None)
2 changes: 1 addition & 1 deletion lldb/test/API/python_api/type/TestTypeList.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test(self):
"my_type_is_named has a named type",
)
self.assertTrue(field.type.IsAggregateType())
elif field.name == None:
elif field.name is None:
self.assertTrue(
field.type.IsAnonymousType(), "Nameless type is not anonymous"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __call__(self, debugger, args, exe_ctx, result):
For the "check" case, it doesn't wait, but just returns whether there was
an interrupt in force or not."""

if local_data == None:
if local_data is None:
result.SetError("local data was not set.")
result.SetStatus(lldb.eReturnStatusFailed)
return
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def calculate_arch_features(arch_string):
if config.lldb_enable_lzma:
config.available_features.add("lzma")

if shutil.which("xz") != None:
if shutil.which("xz") is not None:
config.available_features.add("xz")

if config.lldb_system_debugserver:
Expand Down
Loading