Snap for 6379844 from 0020f68936c101ebc86b9ee74d75bdb389f348d9 to studio-4.1-release

Change-Id: Ia1575d175dd03180d74b139a2f847829eed47846
diff --git a/tools/google-java-format-diff.py b/tools/google-java-format-diff.py
index 4f2bd2d..b804f30 100755
--- a/tools/google-java-format-diff.py
+++ b/tools/google-java-format-diff.py
@@ -27,11 +27,13 @@
 import os
 import platform
 import re
+import six
 import string
-import StringIO
 import subprocess
 import sys
 from distutils.spawn import find_executable
+from io import StringIO
+from six import StringIO
 
 def find_executable_portable(executable):
   if platform.system() == 'Windows':
@@ -104,9 +106,9 @@
           ['-lines', str(start_line) + ':' + str(end_line)])
 
   # Reformat files containing changes in place.
-  for filename, lines in lines_by_file.iteritems():
+  for filename, lines in six.iteritems(lines_by_file):
     if args.i and args.verbose:
-      print 'Formatting', filename
+      print('Formatting %s' % filename)
     command = [binary]
 
     # Windows does not support running bash scripts directly
@@ -132,7 +134,7 @@
       # Open in binary mode to prevent Python from messing with line endings.
       with open(filename, 'rb') as f:
         code = f.readlines()
-      formatted_code = StringIO.StringIO(stdout).readlines()
+      formatted_code = StringIO(stdout.decode('utf-8')).readlines()
       diff = difflib.unified_diff(code, formatted_code,
                                   filename, filename,
                                   '(before formatting)', '(after formatting)')