From 6f86f50ec0650f6b0187c6451cb773e022bfea1e Mon Sep 17 00:00:00 2001 From: nakulj <3213360+nakulj@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:36:51 -0700 Subject: [PATCH] Fix py3 issues with g-j-f-diff - `StringIO` expectes `Text`, not `bytes`. - `string.join(a,b)` is replaced with `b.join(a)` --- scripts/google-java-format-diff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/google-java-format-diff.py b/scripts/google-java-format-diff.py index cf2ded9ec..63f1d2fc4 100755 --- a/scripts/google-java-format-diff.py +++ b/scripts/google-java-format-diff.py @@ -134,11 +134,11 @@ def main(): if not args.i: with open(filename) as f: code = f.readlines() - formatted_code = io.StringIO(stdout).readlines() + formatted_code = io.StringIO(stdout.decode('utf-8')).readlines() diff = difflib.unified_diff(code, formatted_code, filename, filename, '(before formatting)', '(after formatting)') - diff_string = string.join(diff, '') + diff_string = ''.join(diff) if len(diff_string) > 0: sys.stdout.write(diff_string)