aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2023-08-06 02:44:30 +0000
committerMike Frysinger <vapier@chromium.org>2023-08-06 02:45:49 +0000
commit922d49bdfe3c92e5d35c406f87f2c354637a2f8b (patch)
tree79db64c35926bbd12bf7ee34f6ef0287a5596a5c
parent8f6b2527224794dd284aafbdda7fb8a232d4204e (diff)
downloadgoogle-breakpad-922d49bdfe3c92e5d35c406f87f2c354637a2f8b.tar.gz
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>
-rw-r--r--DEPS2
-rwxr-xr-xsrc/tools/python/deps-to-manifest.py7
-rw-r--r--src/tools/python/filter_syms.py9
-rw-r--r--src/tools/python/tests/filter_syms_unittest.py11
4 files changed, 13 insertions, 16 deletions
diff --git a/DEPS b/DEPS
index e08dbd4c..3fcd524d 100644
--- a/DEPS
+++ b/DEPS
@@ -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"],
},
]
diff --git a/src/tools/python/deps-to-manifest.py b/src/tools/python/deps-to-manifest.py
index 2fcaf771..b614f94f 100755
--- a/src/tools/python/deps-to-manifest.py
+++ b/src/tools/python/deps-to-manifest.py
@@ -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 = ''
diff --git a/src/tools/python/filter_syms.py b/src/tools/python/filter_syms.py
index caf3693a..8537769e 100644
--- a/src/tools/python/filter_syms.py
+++ b/src/tools/python/filter_syms.py
@@ -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
diff --git a/src/tools/python/tests/filter_syms_unittest.py b/src/tools/python/tests/filter_syms_unittest.py
index 1081fc73..f6364b8b 100644
--- a/src/tools/python/tests/filter_syms_unittest.py
+++ b/src/tools/python/tests/filter_syms_unittest.py
@@ -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() \ No newline at end of file
+ unittest.main()