Skip to content

Commit 8ff573a

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: adapt csv reader open
Summary: csv.reader have different expectation between Python versions regarding the file object it reads from. On Python 2 it requires the file to have been opened in binary mode while on Python 3 it requires text mode and universal newlines mode enabled but forwarded untranslated to the caller. This commit use an if to cater to both requirements. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, leandron, PrzemekWirkus Reviewed By: PrzemekWirkus Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68800
1 parent 9fda445 commit 8ff573a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lnt/tests/nt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,10 @@ def append_to_sample_keys(tup):
771771
append_to_sample_keys((True, 'jit.exec', 'JIT', 'time'))
772772

773773
# Load the report file.
774-
report_file = open(report_path, 'rb')
774+
if sys.version_info[0] < 3:
775+
report_file = open(report_path, 'rb')
776+
else:
777+
report_file = open(report_path, 'r', newline='')
775778
reader_it = iter(csv.reader(report_file))
776779

777780
# Get the header.

0 commit comments

Comments
 (0)