[clang] 2203089 - [analyzer] exploded-graph-rewriter: Fix string encodings in python3.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 21 11:03:39 PST 2019


Author: Artem Dergachev
Date: 2019-12-21T10:59:38-08:00
New Revision: 2203089a60d826e882e2ccfc5cc5d361b4f91078

URL: https://github.com/llvm/llvm-project/commit/2203089a60d826e882e2ccfc5cc5d361b4f91078
DIFF: https://github.com/llvm/llvm-project/commit/2203089a60d826e882e2ccfc5cc5d361b4f91078.diff

LOG: [analyzer] exploded-graph-rewriter: Fix string encodings in python3.

Makes sure that the script works fine both in python2 and python3.

Patch by Pavel Samolysov!

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index 79055b433e8d..f47be59395a7 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -18,6 +18,7 @@
 import logging
 import os
 import re
+import sys
 
 
 #===-----------------------------------------------------------------------===#
@@ -425,7 +426,10 @@ def _dump_raw(self, s):
 
     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('&', '&') \


        


More information about the cfe-commits mailing list