python: Help Python 2 print the line

Reviewed-by: Jose Fonseca <jfonseca@vmware>
This commit is contained in:
Mathieu Bridon 2018-08-17 09:33:02 -06:00 committed by Brian Paul
parent a8ef7f5e02
commit f9415d760a

View file

@ -218,6 +218,11 @@ for line in template:
assert len(descMatches) == 0
descMatches = [matchDESC_BEGIN]
else:
# In Python 2, stdout expects encoded byte strings, or else it will
# encode them with the ascii 'codec'
if sys.version_info.major == 2:
line = line.encode('utf-8')
print(line, end='')
template.close()