Skip to content

Commit

Permalink
Fix py3 issues with g-j-f-diff
Browse files Browse the repository at this point in the history
- `StringIO` expectes `Text`, not `bytes`.
- `string.join(a,b)` is replaced with `b.join(a)`

Fixes #682

COPYBARA_INTEGRATE_REVIEW=#682 from nakulj:patch-2 6f86f50
PiperOrigin-RevId: 409992189
  • Loading branch information
nakulj authored and google-java-format Team committed Nov 15, 2021
1 parent 5bd619d commit c874114
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/google-java-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c874114

Please sign in to comment.