Skip to content

fix(python): fix comparison to True/False #91858

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

Closed
wants to merge 2 commits into from
Closed
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 clang/tools/scan-build/bin/set-xcode-analyzer
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def main():
foundSpec = True
ModifySpec(x, isBuiltinAnalyzer, path)

if foundSpec == False:
if not foundSpec:
print "(-) No compiler configuration file was found. Xcode's analyzer has not been updated."

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions clang/utils/check_cfc/check_cfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_output_file(args):
elif arg.startswith("-o"):
# Specified conjoined with -o
return arg[2:]
assert grabnext == False
assert not grabnext

return None

Expand All @@ -182,7 +182,7 @@ def replace_output_file(args, new_name):
if replaceidx is None:
raise Exception
replacement = new_name
if attached == True:
if attached:
replacement = "-o" + new_name
args[replaceidx] = replacement
return args
Expand Down
2 changes: 1 addition & 1 deletion lldb/examples/python/crashlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options):
this_thread_crashed = self.app_specific_backtrace
if not this_thread_crashed:
this_thread_crashed = self.did_crash()
if options.crashed_only and this_thread_crashed == False:
if options.crashed_only and not this_thread_crashed:
return

print("%s" % self)
Expand Down
4 changes: 2 additions & 2 deletions lldb/examples/python/disasm-stress-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def GetLLDBFrameworkPath():

debugger = lldb.SBDebugger.Create()

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions lldb/examples/summaries/cocoa/CFString.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def get_child_at_index(self, index):
elif (
self.inline
and self.explicit
and self.unicode == False
and self.special == False
and self.mutable == False
and not self.unicode
and not self.special
and not self.mutable
):
return self.handle_inline_explicit()
elif self.unicode:
Expand Down
2 changes: 1 addition & 1 deletion lldb/examples/summaries/pysummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def pyobj_summary(value, unused):
if value is None or value.IsValid() == False or value.GetValueAsUnsigned(0) == 0:
if value is None or not value.IsValid() or value.GetValueAsUnsigned(0) == 0:
return "<invalid>"
refcnt = value.GetChildMemberWithName("ob_refcnt")
expr = "(char*)PyString_AsString( (PyObject*)PyObject_Str( (PyObject*)0x%x) )" % (
Expand Down
2 changes: 1 addition & 1 deletion lldb/examples/synthetic/bitfield/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_child_at_index(self, index):
return None
if index > self.num_children():
return None
if self.valobj.IsValid() == False:
if not self.valobj.IsValid():
return None
if index == 0:
return self.valobj.GetChildMemberWithName("value")
Expand Down
2 changes: 1 addition & 1 deletion lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,7 @@ def found_str(matched):
log_lines.append(pattern_line)

# Convert to bool because match objects
# are True-ish but != True itself
# are True-ish but is not True itself
matched = bool(matched)
if matched != matching:
break
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/commands/command/script/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def print_wait_impl(debugger, args, result, dict):
def check_for_synchro(debugger, args, result, dict):
if debugger.GetAsync():
print("I am running async", file=result)
if debugger.GetAsync() == False:
if not debugger.GetAsync():
print("I am running sync", file=result)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def call_function(self):

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

self.assertTrue(value.IsValid() and value.GetError().Success() == False)
self.assertTrue(value.IsValid() and not value.GetError().Success())
self.check_after_call()

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

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

self.assertTrue(value.IsValid() and value.GetError().Success() == False)
self.assertTrue(value.IsValid() and not value.GetError().Success())
self.check_after_call()

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

self.assertTrue(value.IsValid() and value.GetError().Success() == False)
self.assertTrue(value.IsValid() and not value.GetError().Success())
self.check_after_call()
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def disassemble_check_for_hi_and_foo(self, target, func, binaryname):
found_hi_string = True
if "foo" in i.GetComment(target):
found_foo = True
if found_hi_string == False or found_foo == False:
if not found_hi_string or not found_foo:
print(
'Did not find "HI" string or "foo" in disassembly symbolication in %s'
% binaryname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def qXferRead(self, obj, annex, offset, length):
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
wp = target.WatchpointCreateByAddress(0x100, 8, wp_opts, err)
if self.TraceOn() and (err.Fail() or wp.IsValid == False):
if self.TraceOn() and (err.Fail() or not wp.IsValid):
strm = lldb.SBStream()
err.GetDescription(strm)
print("watchpoint failed: %s" % strm.GetData())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
for device in devices:
if "availability" in device and device["availability"] != "(available)":
continue
if "isAvailable" in device and device["isAvailable"] != True:
if "isAvailable" in device and device["isAvailable"] is not True:
continue
if deviceRuntime and runtime < deviceRuntime:
continue
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def breakpoint_set_and_remove_work(self, want_hardware):
z_packet_type = 0

# If hardware breakpoint is requested set packet type to Z1
if want_hardware == True:
if want_hardware:
z_packet_type = 1

self.reset_test_sequence()
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/indirect_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def look_for_indirect(file):

function = ""
for line in stdout.splitlines():
if line.startswith(" ") == False:
if not line.startswith(" "):
function = line
result = re.search("(call|jmp).*\*", line)
if result != None:
Expand Down
2 changes: 1 addition & 1 deletion openmp/libompd/gdb-plugin/ompd/ompd.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def invoke(self, arg, from_tty):
"No ompd_dll_locations symbol in execution, make sure to have an OMPD enabled OpenMP runtime"
)

while gdb.parse_and_eval("(char**)ompd_dll_locations") == False:
while not gdb.parse_and_eval("(char**)ompd_dll_locations"):
gdb.execute("tbreak ompd_dll_locations_valid")
gdb.execute("continue")

Expand Down
2 changes: 1 addition & 1 deletion openmp/tools/archer/tests/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if config.operating_system == 'Darwin':
if 'Linux' in config.operating_system:
config.available_features.add("linux")

if config.has_tsan == True:
if config.has_tsan:
config.available_features.add("tsan")

# to run with icc INTEL_LICENSE_FILE must be set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run_test(test, line, name, gmp_test_so, imath_test_so, *args):
if childpid == 0:
eq = test(line, name, gmp_test_so, imath_test_so, *args)
if fork:
sys.exit(eq != True)
sys.exit(not eq)
else:
return eq
else:
Expand Down
Loading