Ran 2to3 to run python code on python3 diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/asan/scripts/asan_symbolize.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/asan/scripts/asan_symbolize.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/asan/scripts/asan_symbolize.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/asan/scripts/asan_symbolize.py 2024-01-11 13:21:54.089653123 +0100 @@ -84,7 +84,7 @@ class LLVMSymbolizer(Symbolizer): for hint in self.dsym_hints: cmd.append('--dsym-hint=%s' % hint) if DEBUG: - print ' '.join(cmd) + print(' '.join(cmd)) try: result = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) @@ -100,8 +100,8 @@ class LLVMSymbolizer(Symbolizer): try: symbolizer_input = '"%s" %s' % (binary, offset) if DEBUG: - print symbolizer_input - print >> self.pipe.stdin, symbolizer_input + print(symbolizer_input) + print(symbolizer_input, file=self.pipe.stdin) while True: function_name = self.pipe.stdout.readline().rstrip() if not function_name: @@ -146,7 +146,7 @@ class Addr2LineSymbolizer(Symbolizer): cmd += ['--demangle'] cmd += ['-e', self.binary] if DEBUG: - print ' '.join(cmd) + print(' '.join(cmd)) return subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) @@ -156,8 +156,8 @@ class Addr2LineSymbolizer(Symbolizer): return None lines = [] try: - print >> self.pipe.stdin, offset - print >> self.pipe.stdin, self.output_terminator + print(offset, file=self.pipe.stdin) + print(self.output_terminator, file=self.pipe.stdin) is_first_frame = True while True: function_name = self.pipe.stdout.readline().rstrip() @@ -214,7 +214,7 @@ class DarwinSymbolizer(Symbolizer): def open_atos(self): if DEBUG: - print 'atos -o %s -arch %s' % (self.binary, self.arch) + print('atos -o %s -arch %s' % (self.binary, self.arch)) cmdline = ['atos', '-o', self.binary, '-arch', self.arch] self.atos = UnbufferedLineConverter(cmdline, close_stderr=True) @@ -229,7 +229,7 @@ class DarwinSymbolizer(Symbolizer): # foo(type1, type2) (in object.name) (filename.cc:80) match = re.match('^(.*) \(in (.*)\) \((.*:\d*)\)$', atos_line) if DEBUG: - print 'atos_line: ', atos_line + print('atos_line: ', atos_line) if match: function_name = match.group(1) function_name = re.sub('\(.*?\)', '', function_name) @@ -304,7 +304,7 @@ class BreakpadSymbolizer(Symbolizer): pass elif fragments[0] == 'FUNC': cur_function_addr = int(fragments[1], 16) - if not cur_function_addr in self.symbols.keys(): + if not cur_function_addr in list(self.symbols.keys()): self.symbols[cur_function_addr] = ' '.join(fragments[4:]) else: # Line starting with an address. @@ -319,7 +319,7 @@ class BreakpadSymbolizer(Symbolizer): def get_sym_file_line(self, addr): key = None - if addr in self.addresses.keys(): + if addr in list(self.addresses.keys()): key = addr else: index = bisect.bisect_left(self.address_list, addr) @@ -343,7 +343,7 @@ class BreakpadSymbolizer(Symbolizer): function_name, file_name, line_no = res result = ['%s in %s %s:%d' % ( addr, function_name, file_name, line_no)] - print result + print(result) return result else: return None @@ -425,7 +425,7 @@ class SymbolizationLoop(object): self.frame_no = 0 for line in logfile: processed = self.process_line(line) - print '\n'.join(processed) + print('\n'.join(processed)) def process_line_echo(self, line): return [line.rstrip()] @@ -439,7 +439,7 @@ class SymbolizationLoop(object): if not match: return [self.current_line] if DEBUG: - print line + print(line) _, frameno_str, addr, binary, offset = match.groups() if frameno_str == '0': # Assume that frame #0 is the first frame of new stack trace. diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/dfsan/scripts/build-libc-list.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/dfsan/scripts/build-libc-list.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/dfsan/scripts/build-libc-list.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/dfsan/scripts/build-libc-list.py 2024-01-11 13:21:54.209651423 +0100 @@ -87,10 +87,10 @@ for l in libs: if os.path.exists(l): functions += defined_function_list(l) else: - print >> sys.stderr, 'warning: library %s not found' % l + print('warning: library %s not found' % l, file=sys.stderr) functions = list(set(functions)) functions.sort() for f in functions: - print 'fun:%s=uninstrumented' % f + print('fun:%s=uninstrumented' % f) diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/cpplint.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/cpplint.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/cpplint.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/cpplint.py 2024-01-11 13:21:54.762976917 +0100 @@ -321,7 +321,7 @@ _ALT_TOKEN_REPLACEMENT = { # and multi-line strings (http://go/beujw ), but those have always been # troublesome for cpplint. _ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( - r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') + r'[ =()](' + ('|'.join(list(_ALT_TOKEN_REPLACEMENT.keys()))) + r')(?=[ (]|$)') # These constants define types of headers for use with @@ -620,7 +620,7 @@ class _CppLintState(object): def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" - for category, count in self.errors_by_category.iteritems(): + for category, count in self.errors_by_category.items(): sys.stderr.write('Category \'%s\' errors found: %d\n' % (category, count)) sys.stderr.write('Total errors found: %d\n' % self.error_count) @@ -1041,7 +1041,7 @@ def FindEndOfExpressionInLine(line, star Returns: Index just after endchar. """ - for i in xrange(startpos, len(line)): + for i in range(startpos, len(line)): if line[i] == startchar: depth += 1 elif line[i] == endchar: @@ -1100,7 +1100,7 @@ def CheckForCopyright(filename, lines, e # We'll say it should occur by line 10. Don't forget there's a # dummy line at the front. - for line in xrange(1, min(len(lines), 11)): + for line in range(1, min(len(lines), 11)): if re.search(r'Copyright', lines[line], re.I): break else: # means no copyright line was found error(filename, 0, 'legal/copyright', 5, @@ -1221,7 +1221,7 @@ def CheckForUnicodeReplacementCharacters error: The function to call with any errors found. """ for linenum, line in enumerate(lines): - if u'\ufffd' in line: + if '\ufffd' in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') @@ -1978,7 +1978,7 @@ def CheckForFunctionLengths(filename, cl if starting_func: body_found = False - for start_linenum in xrange(linenum, clean_lines.NumLines()): + for start_linenum in range(linenum, clean_lines.NumLines()): start_line = lines[start_linenum] joined_line += ' ' + start_line.lstrip() if Search(r'(;|})', start_line): # Declarations and trivial functions @@ -2777,7 +2777,7 @@ def GetLineWidth(line): The width of the line in column positions, accounting for Unicode combining characters and wide characters. """ - if isinstance(line, unicode): + if isinstance(line, str): width = 0 for uc in unicodedata.normalize('NFC', line): if unicodedata.east_asian_width(uc) in ('W', 'F'): @@ -3109,7 +3109,7 @@ def _GetTextInside(text, start_pattern): # Give opening punctuations to get the matching close-punctuations. matching_punctuation = {'(': ')', '{': '}', '[': ']'} - closing_punctuation = set(matching_punctuation.itervalues()) + closing_punctuation = set(matching_punctuation.values()) # Find the position to start extracting text. match = re.search(start_pattern, text, re.M) @@ -3675,7 +3675,7 @@ def CheckForIncludeWhatYouUse(filename, required = {} # A map of header name to linenumber and the template entity. # Example of required: { '': (1219, 'less<>') } - for linenum in xrange(clean_lines.NumLines()): + for linenum in range(clean_lines.NumLines()): line = clean_lines.elided[linenum] if not line or line[0] == '#': continue @@ -3723,7 +3723,7 @@ def CheckForIncludeWhatYouUse(filename, # include_state is modified during iteration, so we iterate over a copy of # the keys. - header_keys = include_state.keys() + header_keys = list(include_state.keys()) for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header @@ -3842,7 +3842,7 @@ def ProcessFileData(filename, file_exten RemoveMultiLineComments(filename, lines, error) clean_lines = CleansedLines(lines) - for line in xrange(clean_lines.NumLines()): + for line in range(clean_lines.NumLines()): ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions) diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/gen_dynamic_list.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/gen_dynamic_list.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/gen_dynamic_list.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/gen_dynamic_list.py 2024-01-11 13:21:54.896308362 +0100 @@ -100,7 +100,7 @@ def main(argv): print('global:') result.sort() for f in result: - print(u' %s;' % f) + print((' %s;' % f)) if args.version_list: print('local:') print(' *;') diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/sancov.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/sancov.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/sancov.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/lib/sanitizer_common/scripts/sancov.py 2024-01-11 13:21:55.032973093 +0100 @@ -14,12 +14,12 @@ import sys prog_name = "" def Usage(): - print >> sys.stderr, "Usage: \n" + \ + print("Usage: \n" + \ " " + prog_name + " merge FILE [FILE...] > OUTPUT\n" \ " " + prog_name + " print FILE [FILE...]\n" \ " " + prog_name + " unpack FILE [FILE...]\n" \ " " + prog_name + " rawunpack FILE [FILE ...]\n" \ - " " + prog_name + " missing BINARY < LIST_OF_PCS\n" + " " + prog_name + " missing BINARY < LIST_OF_PCS\n", file=sys.stderr) exit(1) def CheckBits(bits): @@ -65,15 +65,15 @@ def ReadOneFile(path): bits = ReadMagicAndReturnBitness(f, path) size -= 8 s = array.array(TypeCodeForBits(bits), f.read(size)) - print >>sys.stderr, "%s: read %d %d-bit PCs from %s" % (prog_name, size * 8 / bits, bits, path) + print("%s: read %d %d-bit PCs from %s" % (prog_name, size * 8 / bits, bits, path), file=sys.stderr) return s def Merge(files): s = set() for f in files: s = s.union(set(ReadOneFile(f))) - print >> sys.stderr, "%s: %d files merged; %d PCs total" % \ - (prog_name, len(files), len(s)) + print("%s: %d files merged; %d PCs total" % \ + (prog_name, len(files), len(s)), file=sys.stderr) return sorted(s) def PrintFiles(files): @@ -81,10 +81,10 @@ def PrintFiles(files): s = Merge(files) else: # If there is just on file, print the PCs in order. s = ReadOneFile(files[0]) - print >> sys.stderr, "%s: 1 file merged; %d PCs total" % \ - (prog_name, len(s)) + print("%s: 1 file merged; %d PCs total" % \ + (prog_name, len(s)), file=sys.stderr) for i in s: - print "0x%x" % i + print("0x%x" % i) def MergeAndPrint(files): if sys.stdout.isatty(): @@ -100,7 +100,7 @@ def MergeAndPrint(files): def UnpackOneFile(path): with open(path, mode="rb") as f: - print >> sys.stderr, "%s: unpacking %s" % (prog_name, path) + print("%s: unpacking %s" % (prog_name, path), file=sys.stderr) while True: header = f.read(12) if not header: return @@ -112,8 +112,8 @@ def UnpackOneFile(path): assert(len(module) == module_length) assert(len(blob) == blob_size) extracted_file = "%s.%d.sancov" % (module, pid) - print >> sys.stderr, "%s: extracting %s" % \ - (prog_name, extracted_file) + print("%s: extracting %s" % \ + (prog_name, extracted_file), file=sys.stderr) # The packed file may contain multiple blobs for the same pid/module # pair. Append to the end of the file instead of overwriting. with open(extracted_file, 'ab') as f2: @@ -129,7 +129,7 @@ def Unpack(files): def UnpackOneRawFile(path, map_path): mem_map = [] with open(map_path, mode="rt") as f_map: - print >> sys.stderr, "%s: reading map %s" % (prog_name, map_path) + print("%s: reading map %s" % (prog_name, map_path), file=sys.stderr) bits = int(f_map.readline()) if bits != 32 and bits != 64: raise Exception('Wrong bits size in the map') @@ -143,7 +143,7 @@ def UnpackOneRawFile(path, map_path): mem_map_keys = [m[0] for m in mem_map] with open(path, mode="rb") as f: - print >> sys.stderr, "%s: unpacking %s" % (prog_name, path) + print("%s: unpacking %s" % (prog_name, path), file=sys.stderr) f.seek(0, 2) size = f.tell() @@ -157,7 +157,7 @@ def UnpackOneRawFile(path, map_path): (start, end, base, module_path) = mem_map[map_idx] assert pc >= start if pc >= end: - print >> sys.stderr, "warning: %s: pc %x outside of any known mapping" % (prog_name, pc) + print("warning: %s: pc %x outside of any known mapping" % (prog_name, pc), file=sys.stderr) continue mem_map_pcs[map_idx].append(pc - base) @@ -165,7 +165,7 @@ def UnpackOneRawFile(path, map_path): if len(pc_list) == 0: continue assert path.endswith('.sancov.raw') dst_path = module_path + '.' + os.path.basename(path)[:-4] - print >> sys.stderr, "%s: writing %d PCs to %s" % (prog_name, len(pc_list), dst_path) + print("%s: writing %d PCs to %s" % (prog_name, len(pc_list), dst_path), file=sys.stderr) arr = array.array(TypeCodeForBits(bits)) arr.fromlist(sorted(pc_list)) with open(dst_path, 'ab') as f2: @@ -199,18 +199,17 @@ def PrintMissing(binary): if not os.path.isfile(binary): raise Exception('File not found: %s' % binary) instrumented = GetInstrumentedPCs(binary) - print >> sys.stderr, "%s: found %d instrumented PCs in %s" % (prog_name, + print("%s: found %d instrumented PCs in %s" % (prog_name, len(instrumented), - binary) + binary), file=sys.stderr) covered = set(int(line, 16) for line in sys.stdin) - print >> sys.stderr, "%s: read %d PCs from stdin" % (prog_name, len(covered)) + print("%s: read %d PCs from stdin" % (prog_name, len(covered)), file=sys.stderr) missing = instrumented - covered - print >> sys.stderr, "%s: %d PCs missing from coverage" % (prog_name, len(missing)) + print("%s: %d PCs missing from coverage" % (prog_name, len(missing)), file=sys.stderr) if (len(missing) > len(instrumented) - len(covered)): - print >> sys.stderr, \ - "%s: WARNING: stdin contains PCs not found in binary" % prog_name + print("%s: WARNING: stdin contains PCs not found in binary" % prog_name, file=sys.stderr) for pc in sorted(missing): - print "0x%x" % pc + print("0x%x" % pc) if __name__ == '__main__': prog_name = sys.argv[0] diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_common.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_common.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_common.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_common.py 2024-01-11 13:21:55.146304820 +0100 @@ -10,7 +10,7 @@ if os.environ.get('ANDROID_RUN_VERBOSE') def adb(args): if verbose: - print args + print(args) devnull = open(os.devnull, 'w') return subprocess.call([ADB] + args, stdout=devnull, stderr=subprocess.STDOUT) diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_compile.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_compile.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_compile.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_compile.py 2024-01-11 13:21:55.259636548 +0100 @@ -21,7 +21,7 @@ while args: output = args.pop(0) if output == None: - print "No output file name!" + print("No output file name!") sys.exit(1) ret = subprocess.call(sys.argv[1:]) diff --color -rupN a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_run.py b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_run.py --- a/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_run.py 2020-04-09 07:33:54.000000000 +0200 +++ b/pythondata-software-compiler_rt-2024.04/pythondata_software_compiler_rt/data/test/asan/android_commands/android_run.py 2024-01-11 13:21:55.372968276 +0100 @@ -13,7 +13,7 @@ def build_env(): # Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir. args.append('LD_LIBRARY_PATH=%s:%s' % (ANDROID_TMPDIR, os.environ.get('LD_LIBRARY_PATH', ''))) - for (key, value) in os.environ.items(): + for (key, value) in list(os.environ.items()): if key in ['ASAN_OPTIONS', 'ASAN_ACTIVATION_OPTIONS']: args.append('%s="%s"' % (key, value)) return ' '.join(args)