python: Help Python 2 print the line
authorMathieu Bridon <bochecha@daitauha.fr>
Fri, 17 Aug 2018 15:33:02 +0000 (09:33 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 17 Aug 2018 15:33:16 +0000 (09:33 -0600)
Reviewed-by: Jose Fonseca <jfonseca@vmware>
src/util/xmlpool/gen_xmlpool.py

index 327709c7f8ddac063b4235ad052f2ef4178e092f..64e631f74c43e3cd3948846bf33a40ee0c23b877 100644 (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()