[Piglit] [PATCH] tests: fix unicode issue on MinGW in find_static_tests.py

Ilia Mirkin imirkin at alum.mit.edu
Thu May 3 12:23:35 UTC 2018


On Wed, May 2, 2018 at 10:04 PM, Brian Paul <brianp at vmware.com> wrote:
> Explicity convert strings to unicode before writing.
> This fixes an error when building with MinGW:
> Traceback (most recent call last):
>   File "/var/workspace/tests/find_static_tests.py", line 74, in <module>
>     main()
>   File "/var/workspace/tests/find_static_tests.py", line 69, in main
>     f.write(filename)
> TypeError: write() argument 1 must be unicode, not str
> ---
>  tests/find_static_tests.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/find_static_tests.py b/tests/find_static_tests.py
> index 2152731..6ac1445 100644
> --- a/tests/find_static_tests.py
> +++ b/tests/find_static_tests.py
> @@ -66,8 +66,8 @@ def main():
>      if sorted(files) != sorted(existing):
>          with io.open(args.output, 'wt', encoding='utf-8') as f:
>              for filename in files:
> -                f.write(filename)
> -                f.write('\n')
> +                f.write(unicode(filename))
> +                f.write(unicode('\n'))

Can't you just use "wb" as the open type (and drop the encoding)? Or
something along those lines... That will allow you to operate the file
in a more intuitive way and not worry about all this unicode stuff.

I'm not sure what just doing unicode() on a string will do. Normally
you specify a charset so that it can interpret the sequence of bytes
as unicode code points.

  -ilia


More information about the Piglit mailing list