Py3k compliance: check for bytes when making a string
When faking stdout in tests we must account for the case when "strings" might be bytes, which python3 cares about. Change-Id: I0e9349c86371055eed479799d39ab6adbcad6f95 Closes-Bug: #1499004
This commit is contained in:
@@ -73,6 +73,12 @@ class FakeStdout(object):
|
|||||||
def make_string(self):
|
def make_string(self):
|
||||||
result = ''
|
result = ''
|
||||||
for line in self.content:
|
for line in self.content:
|
||||||
|
if six.PY3:
|
||||||
|
if isinstance(line, bytes):
|
||||||
|
try:
|
||||||
|
line = line.decode(encoding='utf-8')
|
||||||
|
except UnicodeError:
|
||||||
|
pass
|
||||||
result = result + line
|
result = result + line
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user