From d99432b137983b2898aaa5286cca1aeb4b804700 Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Wed, 24 Jul 2019 19:07:10 +0900
Subject: [PATCH] Support python3

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
 src/build_mozc.py                           | 18 +++++++++---------
 src/build_tools/android_util.py             |  2 +-
 src/build_tools/test_tools/test_launcher.py |  4 ++--
 src/build_tools/util.py                     |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/build_mozc.py b/src/build_mozc.py
index 46fa0827..910137d7 100644
--- a/src/build_mozc.py
+++ b/src/build_mozc.py
@@ -943,7 +943,7 @@ def RunTests(target_platform, configuration, parallel_num):
       logging.info('running %s...', binary)
       try:
         test_function(binary, gtest_report_dir, options)
-      except RunOrDieError, e:
+      except RunOrDieError as e:
         logging.error(e)
         failed_tests.append(binary)
   else:
@@ -1190,14 +1190,14 @@ def CleanMain(options, unused_args):
 
 def ShowHelpAndExit():
   """Shows the help message."""
-  print 'Usage: build_mozc.py COMMAND [ARGS]'
-  print 'Commands: '
-  print '  gyp          Generate project files.'
-  print '  build        Build the specified target.'
-  print '  runtests     Build all tests and run them.'
-  print '  clean        Clean all the build files and directories.'
-  print ''
-  print 'See also the comment in the script for typical usage.'
+  print ('Usage: build_mozc.py COMMAND [ARGS]')
+  print ('Commands: ')
+  print ('  gyp          Generate project files.')
+  print ('  build        Build the specified target.')
+  print ('  runtests     Build all tests and run them.')
+  print ('  clean        Clean all the build files and directories.')
+  print ('')
+  print ('See also the comment in the script for typical usage.')
   sys.exit(1)
 
 
diff --git a/src/build_tools/android_util.py b/src/build_tools/android_util.py
index 5ea3da31..20989a5b 100644
--- a/src/build_tools/android_util.py
+++ b/src/build_tools/android_util.py
@@ -615,7 +615,7 @@ def GetAvdProperties(android_sdk_home, avd_name, my_open=open):
 def main():
   for arg in sys.argv[1:]:
     for item in sorted(GetApkProperties(arg).items()):
-      print '%s: %s' % item
+      print ('%s: %s' % item)
 
 
 if __name__ == '__main__':
diff --git a/src/build_tools/test_tools/test_launcher.py b/src/build_tools/test_tools/test_launcher.py
index 47c0a2ec..ac6a50da 100644
--- a/src/build_tools/test_tools/test_launcher.py
+++ b/src/build_tools/test_tools/test_launcher.py
@@ -101,11 +101,11 @@ class PathDeleter(object):
       time.sleep(1)
       try:
         shutil.rmtree(self._path)
-      except OSError, e:
+      except OSError as e:
         logging.error('Failed to remove %s. error: %s', self._path, e)
 
 
-def _ExecuteTest((command, gtest_report_dir)):
+def _ExecuteTest(command, gtest_report_dir):
   """Executes tests with specified Test command.
 
   Args:
diff --git a/src/build_tools/util.py b/src/build_tools/util.py
index 85961187..3527f9e2 100644
--- a/src/build_tools/util.py
+++ b/src/build_tools/util.py
@@ -73,7 +73,7 @@ def GetNumberOfProcessors():
   return 1
 
 
-class RunOrDieError(StandardError):
+class RunOrDieError(Exception):
   """The exception class for RunOrDie."""
 
   def __init__(self, message):
@@ -105,7 +105,7 @@ def RemoveFile(file_name):
     return  # Do nothing if not exist.
   if IsWindows():
     # Read-only files cannot be deleted on Windows.
-    os.chmod(file_name, 0700)
+    os.chmod(file_name, 0o700)
   logging.debug('Removing file: %s', file_name)
   os.unlink(file_name)
 
-- 
2.20.1

