Skip to content

Commit fd35a92

Browse files
authored
[lldb] fix(lldb/**.py): fix comparison to True/False (#94039)
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 019f525 commit fd35a92

File tree

12 files changed

+17
-17
lines changed

12 files changed

+17
-17
lines changed

lldb/examples/python/crashlog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options):
166166
this_thread_crashed = self.app_specific_backtrace
167167
if not this_thread_crashed:
168168
this_thread_crashed = self.did_crash()
169-
if options.crashed_only and this_thread_crashed == False:
169+
if options.crashed_only and not this_thread_crashed:
170170
return
171171

172172
print("%s" % self)

lldb/examples/python/disasm-stress-test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ def GetLLDBFrameworkPath():
9595

9696
debugger = lldb.SBDebugger.Create()
9797

98-
if debugger.IsValid() == False:
98+
if not debugger.IsValid():
9999
print("Couldn't create an SBDebugger")
100100
sys.exit(-1)
101101

102102
target = debugger.CreateTargetWithFileAndArch(None, arg_ns.arch)
103103

104-
if target.IsValid() == False:
104+
if not target.IsValid():
105105
print("Couldn't create an SBTarget for architecture " + arg_ns.arch)
106106
sys.exit(-1)
107107

lldb/examples/summaries/cocoa/CFString.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ def get_child_at_index(self, index):
253253
elif (
254254
self.inline
255255
and self.explicit
256-
and self.unicode == False
257-
and self.special == False
258-
and self.mutable == False
256+
and not self.unicode
257+
and not self.special
258+
and not self.mutable
259259
):
260260
return self.handle_inline_explicit()
261261
elif self.unicode:

lldb/examples/summaries/pysummary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def pyobj_summary(value, unused):
5-
if value is None or value.IsValid() == False or value.GetValueAsUnsigned(0) == 0:
5+
if value is None or not value.IsValid() or value.GetValueAsUnsigned(0) == 0:
66
return "<invalid>"
77
refcnt = value.GetChildMemberWithName("ob_refcnt")
88
expr = "(char*)PyString_AsString( (PyObject*)PyObject_Str( (PyObject*)0x%x) )" % (

lldb/examples/synthetic/bitfield/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_child_at_index(self, index):
5151
return None
5252
if index > self.num_children():
5353
return None
54-
if self.valobj.IsValid() == False:
54+
if not self.valobj.IsValid():
5555
return None
5656
if index == 0:
5757
return self.valobj.GetChildMemberWithName("value")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ def found_str(matched):
24462446
log_lines.append(pattern_line)
24472447

24482448
# Convert to bool because match objects
2449-
# are True-ish but != True itself
2449+
# are True-ish but is not True itself
24502450
matched = bool(matched)
24512451
if matched != matching:
24522452
break

lldb/test/API/commands/command/script/welcome.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def print_wait_impl(debugger, args, result, dict):
4545
def check_for_synchro(debugger, args, result, dict):
4646
if debugger.GetAsync():
4747
print("I am running async", file=result)
48-
if debugger.GetAsync() == False:
48+
if not debugger.GetAsync():
4949
print("I am running sync", file=result)
5050

5151

lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def call_function(self):
6161

6262
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
6363

64-
self.assertTrue(value.IsValid() and value.GetError().Success() == False)
64+
self.assertTrue(value.IsValid() and not value.GetError().Success())
6565
self.check_after_call()
6666

6767
# Now set the ObjC language breakpoint and make sure that doesn't
@@ -76,7 +76,7 @@ def call_function(self):
7676

7777
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
7878

79-
self.assertTrue(value.IsValid() and value.GetError().Success() == False)
79+
self.assertTrue(value.IsValid() and not value.GetError().Success())
8080
self.check_after_call()
8181

8282
# Now turn off exception trapping, and call a function that catches the exceptions,
@@ -95,5 +95,5 @@ def call_function(self):
9595
options.SetUnwindOnError(False)
9696
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
9797

98-
self.assertTrue(value.IsValid() and value.GetError().Success() == False)
98+
self.assertTrue(value.IsValid() and not value.GetError().Success())
9999
self.check_after_call()

lldb/test/API/functionalities/disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def disassemble_check_for_hi_and_foo(self, target, func, binaryname):
5757
found_hi_string = True
5858
if "foo" in i.GetComment(target):
5959
found_foo = True
60-
if found_hi_string == False or found_foo == False:
60+
if not found_hi_string or not found_foo:
6161
print(
6262
'Did not find "HI" string or "foo" in disassembly symbolication in %s'
6363
% binaryname

lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def qXferRead(self, obj, annex, offset, length):
6161
wp_opts = lldb.SBWatchpointOptions()
6262
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
6363
wp = target.WatchpointCreateByAddress(0x100, 8, wp_opts, err)
64-
if self.TraceOn() and (err.Fail() or wp.IsValid == False):
64+
if self.TraceOn() and (err.Fail() or not wp.IsValid):
6565
strm = lldb.SBStream()
6666
err.GetDescription(strm)
6767
print("watchpoint failed: %s" % strm.GetData())

lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
3939
for device in devices:
4040
if "availability" in device and device["availability"] != "(available)":
4141
continue
42-
if "isAvailable" in device and device["isAvailable"] != True:
42+
if "isAvailable" in device and not device["isAvailable"]:
4343
continue
4444
if deviceRuntime and runtime < deviceRuntime:
4545
continue

lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def breakpoint_set_and_remove_work(self, want_hardware):
953953
z_packet_type = 0
954954

955955
# If hardware breakpoint is requested set packet type to Z1
956-
if want_hardware == True:
956+
if want_hardware:
957957
z_packet_type = 1
958958

959959
self.reset_test_sequence()

0 commit comments

Comments
 (0)