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

Dylan Baker dylan at pnwbakers.com
Thu May 3 17:15:39 UTC 2018


Quoting Brian Paul (2018-05-03 07:53:04)
> 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

I had sent a different patch for this yesterday as well, it converts the bytes
into unicode in python2. We definately cannot use this patch as is, since
unicode isn't defined in python3. We could use bytes, but that would require
additional changes.

Dylan
-------------- 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/piglit/attachments/20180503/664f7bac/attachment.sig>


More information about the Piglit mailing list