Update scripts to Python 3

Python 2 is deprecated and have now been removed from CI builders.

Change-Id: Ic838714502e16136bd8ed345a47a00b71ff889aa
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4754416
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Petr Hosek 2023-08-06 02:44:30 +00:00 committed by Mike Frysinger
parent 8f6b252722
commit 922d49bdfe
4 changed files with 13 additions and 16 deletions

2
DEPS
View file

@ -52,7 +52,7 @@ deps = {
hooks = [
{
# Keep the manifest up to date.
"action": ["python", "src/src/tools/python/deps-to-manifest.py",
"action": ["src/src/tools/python/deps-to-manifest.py",
"src/DEPS", "src/default.xml"],
},
]

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright 2016 Google LLC
#
# Redistribution and use in source and binary forms, with or without
@ -29,8 +29,6 @@
"""Convert gclient's DEPS file to repo's manifest xml file."""
from __future__ import print_function
import argparse
import os
import sys
@ -76,7 +74,8 @@ def ConvertDepsToManifest(deps, manifest):
"""Convert the |deps| file to the |manifest|."""
# Load the DEPS file data.
ctx = {}
execfile(deps, ctx)
with open(deps, 'rb') as file:
exec(compile(file.read(), deps, 'exec'), ctx)
new_contents = ''

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2012 Google LLC
#
# Redistribution and use in source and binary forms, with or without
@ -38,7 +38,6 @@ DWARF files and normalize and de-duplicate the FILE records found within,
updating any references to the FILE records in the other record types.
"""
import macpath
import ntpath
import optparse
import os
@ -132,8 +131,8 @@ class SymbolFileParser(object):
Returns:
The actual path to use when writing the FILE record.
"""
return path[len(filter(path.startswith,
self.ignored_prefixes + [''])[0]):]
return path[len(next(filter(path.startswith,
self.ignored_prefixes + ['']))):]
def _ParseFileRecord(self, file_record):
"""Parses and corrects a FILE record."""
@ -193,7 +192,7 @@ def main():
symbol_parser = SymbolFileParser(sys.stdin, sys.stdout, options.prefixes,
path_handler)
symbol_parser.Process()
except BreakpadParseError, e:
except BreakpadParseError as e:
print >> sys.stderr, 'Got an error while processing symbol file'
print >> sys.stderr, str(e)
return 1

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2012 Google LLC
#
# Redistribution and use in source and binary forms, with or without
@ -29,10 +29,9 @@
"""Unit tests for filter_syms.py"""
import cStringIO
import io
import ntpath
import os
import StringIO
import sys
import unittest
@ -44,8 +43,8 @@ import filter_syms
class FilterSysmsTest(unittest.TestCase):
def assertParsed(self, input_data, ignored_prefixes, expected):
input_io = cStringIO.StringIO(input_data)
output_io = cStringIO.StringIO()
input_io = io.StringIO(input_data)
output_io = io.StringIO()
parser = filter_syms.SymbolFileParser(input_io, output_io,
ignored_prefixes, ntpath)
parser.Process()
@ -134,4 +133,4 @@ FUNC 1000 c 0 Function1_1
self.assertParsed(INPUT, IGNORED_PREFIXES, EXPECTED_OUTPUT)
if __name__ == '__main__':
unittest.main()
unittest.main()