diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-07-01 13:22:06 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-08-05 10:45:05 -0700 |
commit | e2a60f72805aab6271d4155639ea0ea87a026749 (patch) | |
tree | 7f743ec32320941d160b4dc72657ff823ea51c41 /framework/status.py | |
parent | 28434522f363864a882f20e0a9301796858f3417 (diff) |
framework: fix two bugs in status
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@intel.com>
Diffstat (limited to 'framework/status.py')
-rw-r--r-- | framework/status.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/framework/status.py b/framework/status.py index c01adaf3d..c69c50ae0 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 |