[llvm] r352633 - [utils] Fix update scripts output when run on python3.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 30 08:15:59 PST 2019


Author: rksimon
Date: Wed Jan 30 08:15:59 2019
New Revision: 352633

URL: http://llvm.org/viewvc/llvm-project?rev=352633&view=rev
Log:
[utils] Fix update scripts output when run on python3.

This fixes a "bytes-like object is required, not 'str'" python3 error I hit on update_llc_test_checks.py (but present on the other scripts as well) by matching what update_mca_test_checks.py already does, plus I've added an explicit 'utf-8' encoding.

Modified:
    llvm/trunk/utils/update_analyze_test_checks.py
    llvm/trunk/utils/update_llc_test_checks.py
    llvm/trunk/utils/update_mca_test_checks.py
    llvm/trunk/utils/update_test_checks.py

Modified: llvm/trunk/utils/update_analyze_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_analyze_test_checks.py?rev=352633&r1=352632&r2=352633&view=diff
==============================================================================
--- llvm/trunk/utils/update_analyze_test_checks.py (original)
+++ llvm/trunk/utils/update_analyze_test_checks.py Wed Jan 30 08:15:59 2019
@@ -186,7 +186,7 @@ def main():
       print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
 
     with open(test, 'wb') as f:
-      f.writelines([l + '\n' for l in output_lines])
+      f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 
 if __name__ == '__main__':

Modified: llvm/trunk/utils/update_llc_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_llc_test_checks.py?rev=352633&r1=352632&r2=352633&view=diff
==============================================================================
--- llvm/trunk/utils/update_llc_test_checks.py (original)
+++ llvm/trunk/utils/update_llc_test_checks.py Wed Jan 30 08:15:59 2019
@@ -172,7 +172,7 @@ def main():
       print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
 
     with open(test, 'wb') as f:
-      f.writelines([l + '\n' for l in output_lines])
+      f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 
 if __name__ == '__main__':

Modified: llvm/trunk/utils/update_mca_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_mca_test_checks.py?rev=352633&r1=352632&r2=352633&view=diff
==============================================================================
--- llvm/trunk/utils/update_mca_test_checks.py (original)
+++ llvm/trunk/utils/update_mca_test_checks.py Wed Jan 30 08:15:59 2019
@@ -551,7 +551,7 @@ def _write_output(test_path, input_lines
         'Writing {} lines to {}...\n\n'.format(len(output_lines), test_path))
 
   with open(test_path, 'wb') as f:
-    f.writelines(['{}\n'.format(l).encode() for l in output_lines])
+    f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 def main():
   args = _parse_args()

Modified: llvm/trunk/utils/update_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_test_checks.py?rev=352633&r1=352632&r2=352633&view=diff
==============================================================================
--- llvm/trunk/utils/update_test_checks.py (original)
+++ llvm/trunk/utils/update_test_checks.py Wed Jan 30 08:15:59 2019
@@ -183,7 +183,7 @@ def main():
       print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
 
     with open(test, 'wb') as f:
-      f.writelines([l + '\n' for l in output_lines])
+      f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 
 if __name__ == '__main__':




More information about the llvm-commits mailing list