From 3ed6c994d252f43f90d03a1ca2bd9cf694563513 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 2 Jul 2020 11:49:26 -0700 Subject: [PATCH 1/2] test: make `validate_parse` more python3 friendly Use `io.open` to open the files with the correct encoding and to allow proper newline specification. This allows the script to be python 2 and python 3 compatible. --- utils/incrparse/validate_parse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/incrparse/validate_parse.py b/utils/incrparse/validate_parse.py index 6d62d90fb5a18..cef5c8733f9dd 100755 --- a/utils/incrparse/validate_parse.py +++ b/utils/incrparse/validate_parse.py @@ -4,6 +4,7 @@ import argparse import difflib +import io import os import sys @@ -108,8 +109,8 @@ def main(): sys.exit(1) # Check if the two syntax trees are the same - lines = difflib.unified_diff(open(incremental_serialized_file).readlines(), - open(post_edit_serialized_file).readlines(), + lines = difflib.unified_diff(io.open(incremental_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(), + io.open(post_edit_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(), fromfile=incremental_serialized_file, tofile=post_edit_serialized_file) diff = '\n'.join(line for line in lines) From 58d0cbcaeaa1664a4fc561ab851fbcbdf2714206 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 3 Jul 2020 12:41:47 -0700 Subject: [PATCH 2/2] Update validate_parse.py Attempt to appease the python linter --- utils/incrparse/validate_parse.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/incrparse/validate_parse.py b/utils/incrparse/validate_parse.py index cef5c8733f9dd..8f69591fb8aaa 100755 --- a/utils/incrparse/validate_parse.py +++ b/utils/incrparse/validate_parse.py @@ -109,8 +109,10 @@ def main(): sys.exit(1) # Check if the two syntax trees are the same - lines = difflib.unified_diff(io.open(incremental_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(), - io.open(post_edit_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(), + lines = difflib.unified_diff(io.open(incremental_serialized_file, 'r', + encoding='utf-8', errors='ignore').readlines(), + io.open(post_edit_serialized_file, 'r', + encoding='utf-8', errors='ignore').readlines(), fromfile=incremental_serialized_file, tofile=post_edit_serialized_file) diff = '\n'.join(line for line in lines)