[Mesa-dev] [PATCH 1/3] python: difflib prefers unicode strings

Dylan Baker dylan at pnwbakers.com
Fri Aug 17 19:52:08 UTC 2018


for the series:
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>

Quoting Mathieu Bridon (2018-08-17 12:32:16)
> 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.
> ---
>  src/compiler/glsl/glcpp/tests/glcpp_test.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> index 8ac5d7cb0a1..e27391093cf 100755
> --- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
> +++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> @@ -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:
> -- 
> 2.17.1
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180817/adf2a9a7/attachment.sig>


More information about the mesa-dev mailing list