[Piglit] [PATCH 1/2] framework: fix unicode input for python 2.x

Dylan Baker baker.dylan.c at gmail.com
Wed Mar 30 17:39:50 UTC 2016


Quoting Jan Vesely (2016-03-29 21:24:28)
> On Fri, 2016-03-25 at 14:28 -0700, Dylan Baker wrote:
> > In python 3.x input is unicode by default, but in python 2.x
> > everything
> > is a byte string by default, this includes input. Currently when
> > running
> > with python 3.x it's possible to use unicode for input, but python
> > 2.x
> > will choke when it tries to encode the bytes into unicode using the
> > ascii codec.
> > 
> > For example, this will work with python 3.x but no with python 2.x:
> > (The character is yuki, Japanese for snow, if memory serves)
> > ./piglit run quick 雪 -c
> > 
> > This is actually pretty easy to fix, when runnging with python 2.x
> > decode each input element into unicode using utf-8 as soon as the
> > input
> > is received.
> > 
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> 
> This breaks all partial commands with python3. only ./piglit checks
> python version, the rest try to do decode unconditionally. Is this
> intended?
> 
> 
> $ python3 ./piglit-print-commands.py tests/cl.py
> Traceback (most recent call last):
>   File "./piglit-print-commands.py", line 89, in <module>
>     main()
>   File "./piglit-print-commands.py", line 41, in main
>     input_ = [i.decode('utf-8') for i in sys.argv[1:]]
>   File "./piglit-print-commands.py", line 41, in <listcomp>
>     input_ = [i.decode('utf-8') for i in sys.argv[1:]]
> AttributeError: 'str' object has no attribute 'decode'
> 
> Jan
> 

Uh, we should probably check for python2 there too. I actually didn't
realize that print-commands even worked with python3. I can send out a
patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160330/7f55212d/attachment.sig>


More information about the Piglit mailing list