[analyzer] exploded-graph-rewriter: Fix string encodings in python3.
authorArtem Dergachev <artem.dergachev@gmail.com>
Sat, 21 Dec 2019 18:57:03 +0000 (10:57 -0800)
committerArtem Dergachev <artem.dergachev@gmail.com>
Sat, 21 Dec 2019 18:59:38 +0000 (10:59 -0800)
Makes sure that the script works fine both in python2 and python3.

Patch by Pavel Samolysov!

Differential Revision: https://reviews.llvm.org/D71746

clang/utils/analyzer/exploded-graph-rewriter.py

index 79055b4..f47be59 100755 (executable)
@@ -18,6 +18,7 @@ import json
 import logging
 import os
 import re
+import sys
 
 
 #===-----------------------------------------------------------------------===#
@@ -425,7 +426,10 @@ class DotDumpVisitor(object):
 
     def output(self):
         assert not self._dump_dot_only
-        return ''.join(self._output)
+        if sys.version_info[0] > 2 and sys.version_info[1] >= 5:
+            return ''.join(self._output).encode()
+        else:
+            return ''.join(self._output)
 
     def _dump(self, s):
         s = s.replace('&', '&amp;') \