python: difflib prefers unicode strings
authorMathieu Bridon <bochecha@daitauha.fr>
Fri, 17 Aug 2018 19:32:16 +0000 (21:32 +0200)
committerDylan Baker <dylan@pnwbakers.com>
Wed, 22 Aug 2018 15:41:01 +0000 (08:41 -0700)
Python 3 does not automatically convert from bytes to unicode strings
like Python 2 used to do.

This commit makes sure we pass unicode strings to difflib.unified_diff,
so that the script works on both Python 2 and 3.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
src/compiler/glsl/glcpp/tests/glcpp_test.py

index 8ac5d7cb0a1b9d05c1c293d58c2a1a8ac55a13ac..e27391093cf03d52f15a25730d4b9be479a7e8b8 100755 (executable)
@@ -64,8 +64,9 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
             stderr=subprocess.STDOUT,
             stdin=subprocess.PIPE)
         actual, _ = proc.communicate(f.read())
+        actual = actual.decode('utf-8')
 
-    with open(expfile, 'rb') as f:
+    with open(expfile, 'r') as f:
         expected = f.read()
 
     if actual == expected: