Skip to content

Commit 3ed6c99

Browse files
committed
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.
1 parent d87e7c8 commit 3ed6c99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

utils/incrparse/validate_parse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import argparse
66
import difflib
7+
import io
78
import os
89
import sys
910

@@ -108,8 +109,8 @@ def main():
108109
sys.exit(1)
109110

110111
# Check if the two syntax trees are the same
111-
lines = difflib.unified_diff(open(incremental_serialized_file).readlines(),
112-
open(post_edit_serialized_file).readlines(),
112+
lines = difflib.unified_diff(io.open(incremental_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(),
113+
io.open(post_edit_serialized_file, 'r', encoding='utf-8', errors='ignore').readlines(),
113114
fromfile=incremental_serialized_file,
114115
tofile=post_edit_serialized_file)
115116
diff = '\n'.join(line for line in lines)

0 commit comments

Comments
 (0)