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

Brian Paul brianp at vmware.com
Thu May 3 14:53:04 UTC 2018


On 05/03/2018 06:23 AM, Ilia Mirkin wrote:
> 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.

That works too.  I'll let Dylan choose what he wants.  I'm just trying 
to get things working again and have no preference.


> 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.

FWIW, I also tried filename.encode('utf-8') but that did not work.

-Brian



More information about the Piglit mailing list