Ensure to decode bytes or fail
The commitfcf289797c
introduces the pattern: if isinstance(line, bytes): try: line = line.decode(encoding='utf-8') except UnicodeError: pass # concat line with a string which is not working in PY3K if an UnicodeError is raised because line is not decoded and concatened to a string. This change delegates decoding to safe_decode[1] which returns a text object or raises an error. [1] oslo_utils.encodeutils Closes-Bug: #1503415 Related-Bug: #1499004 Change-Id: I16b8013f33aa3efad65be8040d3210120e047bbd (cherry picked from commit88eb5845b7
)
This commit is contained in:
parent
c816799185
commit
c5e1d2b827
|
@ -73,13 +73,7 @@ class FakeStdout(object):
|
|||
def make_string(self):
|
||||
result = ''
|
||||
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 += encodeutils.safe_decode(line, 'utf-8')
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue