[PATCH] D68800: [LNT] Python 3 support: adapt csv reader open

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 08:50:09 PDT 2019


thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls.
thopre added a parent revision: D68799: [LNT] Fix sql index name collision.
thopre added a child revision: D68801: [LNT] Python 3 support: print unknown metric with str.

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.


https://reviews.llvm.org/D68800

Files:
  lnt/tests/nt.py


Index: lnt/tests/nt.py
===================================================================
--- lnt/tests/nt.py
+++ lnt/tests/nt.py
@@ -771,7 +771,10 @@
             append_to_sample_keys((True, 'jit.exec', 'JIT', 'time'))
 
     # Load the report file.
-    report_file = open(report_path, 'rb')
+    if sys.version_info[0] < 3:
+        report_file = open(report_path, 'rb')
+    else:
+        report_file = open(report_path, 'r', newline='')
     reader_it = iter(csv.reader(report_file))
 
     # Get the header.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68800.224366.patch
Type: text/x-patch
Size: 517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/5ea16c87/attachment.bin>


More information about the llvm-commits mailing list