[PATCH] D64129: [clang-scan-view] Force utf-8 when handling report (python2 only)

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 04:07:18 PDT 2019


serge-sans-paille created this revision.
serge-sans-paille added a reviewer: michaelplatings.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the report file contains unicode characters, under Python2, opening the file does not decode it to utf-8 by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64129

Files:
  clang/tools/scan-view/share/ScanView.py


Index: clang/tools/scan-view/share/ScanView.py
===================================================================
--- clang/tools/scan-view/share/ScanView.py
+++ clang/tools/scan-view/share/ScanView.py
@@ -764,11 +764,11 @@
             variables['report'] = m.group(2)
 
         try:
-            f = open(path,'r')
+            f = open(path,'rb')
         except IOError:
             return self.send_404()
         fs = os.fstat(f.fileno())
-        data = f.read()
+        data = f.read().decode('utf-8')
         for a,b in kReportReplacements:
             data = a.sub(b % variables, data)
         return self.send_string(data, ctype, mtime=fs.st_mtime)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64129.207752.patch
Type: text/x-patch
Size: 667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190703/3bc0aad2/attachment.bin>


More information about the cfe-commits mailing list