[Piglit] [PATCH 0/2] Fix python 2 unicode handling bugs

Dylan Baker baker.dylan.c at gmail.com
Fri Mar 25 21:28:26 UTC 2016

This small series fixes two distinct bugs in piglit's python2 unicode

The first bug is related to input. For python 2.x (and not python 3.x)
input is currently left as byte strings (str in python 2 types), this
means that if anything that isn't ascii encodable is passed in as input
then piglit will choke somewhere within when it tries to coerce that
byte string into unicode (which it will do). The solution is to simply
decode all input into unicode objects when piglit starts in python2.

The second is related to html summary generation. If there is unicode in
any of the templates they will choke when writing. This is because,
again, they are bytes strings and will choke on anything that python 2
cant coerce into unicode. Python 3 handles this correctly because mako
returns unicode objects there. The solution here is the opposite, it's
easier to change python 3 to return bytes, but to explicitly encode
them as UTF-8 (it's what the HTML templates have always claimed they're
encoded as anyway).

Marek, can you see if this solves the problems you reported earlier?

Dylan Baker (2):
  framework: fix unicode input for python 2.x
  framework/summary/html_.py: Write output files as utf-8 bytes streams

 framework/summary/html_.py | 17 ++++++++++++-----
 piglit                     | 17 +++++++++++++----
 piglit-print-commands.py   |  7 +++++--
 piglit-resume.py           |  6 +++++-
 piglit-run.py              |  6 +++++-
 piglit-summary-html.py     |  6 +++++-
 piglit-summary.py          |  6 +++++-
 7 files changed, 50 insertions(+), 15 deletions(-)


More information about the Piglit mailing list