Skip to content

Commit 5861145

Browse files
authored
[lldb] fix(lldb/**.py): fix comparison to None (#94017)
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 fd35a92 commit 5861145

File tree

18 files changed

+26
-26
lines changed

18 files changed

+26
-26
lines changed

lldb/bindings/interface/SBBreakpointDocstrings.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TestBreakpointIgnoreCount.py),::
3939
#lldbutil.print_stacktraces(process)
4040
from lldbutil import get_stopped_thread
4141
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
42-
self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
42+
self.assertTrue(thread is not None, 'There should be a thread stopped due to breakpoint')
4343
frame0 = thread.GetFrameAtIndex(0)
4444
frame1 = thread.GetFrameAtIndex(1)
4545
frame2 = thread.GetFrameAtIndex(2)

lldb/bindings/interface/SBDataExtensions.i

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ STRING_EXTENSION_OUTSIDE(SBData)
4040
lldbtarget = lldbdict['target']
4141
else:
4242
lldbtarget = None
43-
if target == None and lldbtarget != None and lldbtarget.IsValid():
43+
if target is None and lldbtarget is not None and lldbtarget.IsValid():
4444
target = lldbtarget
45-
if ptr_size == None:
45+
if ptr_size is None:
4646
if target and target.IsValid():
4747
ptr_size = target.addr_size
4848
else:
4949
ptr_size = 8
50-
if endian == None:
50+
if endian is None:
5151
if target and target.IsValid():
5252
endian = target.byte_order
5353
else:
5454
endian = lldbdict['eByteOrderLittle']
55-
if size == None:
55+
if size is None:
5656
if value > 2147483647:
5757
size = 8
5858
elif value < -2147483648:

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)

0 commit comments

Comments
 (0)