[Piglit] [PATCH 44/49] framework: fix two bugs in status
Dylan Baker
dylan at pnwbakers.com
Fri Jul 29 18:39:30 UTC 2016
The Status.__bytes__ method is broken in python3 since it doesn't
provide an encoding currently, and __repr__ should be returning a value
that can be used by exec() to recreate the class. To fix bytes we
actually need to have different paths for python 2 and python 3, since
python 2's str() doesn't have an encoding argument.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/status.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/framework/status.py b/framework/status.py
index c01adaf..c69c50a 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -165,10 +165,14 @@ class Status(object):
return self.__fraction
def __repr__(self):
- return self.name
+ return 'Status("{}", {}, {})'.format(
+ self.name, self.value, self.fraction)
def __bytes__(self):
- return six.binary_type(self.name)
+ if six.PY2:
+ return str(self.name)
+ elif six.PY3:
+ return bytes(self.name, 'utf-8')
def __str__(self):
return self.name
--
2.9.0
More information about the Piglit
mailing list