[PATCH] D37661: [sancov] coverage-report-server.py: ServerHandler(): open file as UTF8
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 9 03:11:49 PDT 2017
lebedev.ri created this revision.
lebedev.ri added a project: Sanitizers.
This is nessesary in Python3. Everywhere else we assume that
encoding is UTF8. If we don't specify it here, the defaults
from the environment will be used, which may result in ASCII
decoder being used. And if the file is non-ASCII, then it
will crash:
File "/usr/local/bin/coverage-report-server.py", line 168, in do_GET
for line_no, line in enumerate(f, start=1)])
File "/usr/local/bin/coverage-report-server.py", line 165, in <listcomp>
["<span class='{cls}'>{line} </span>".format(
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 106: ordinal not in range(128)
Fixes https://bugs.llvm.org/show_bug.cgi?id=33548
Now, how would i add a testcase here?
Repository:
rL LLVM
https://reviews.llvm.org/D37661
Files:
tools/sancov/coverage-report-server.py
Index: tools/sancov/coverage-report-server.py
===================================================================
--- tools/sancov/coverage-report-server.py
+++ tools/sancov/coverage-report-server.py
@@ -160,7 +160,7 @@
linemap = self.symcov_data.compute_linemap(filename)
- with open(filepath, 'r') as f:
+ with open(filepath, 'r', encoding='utf8') as f:
content = "\n".join(
["<span class='{cls}'>{line} </span>".format(
line=html.escape(line.rstrip()),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37661.114480.patch
Type: text/x-patch
Size: 572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170909/c546d88d/attachment.bin>
More information about the llvm-commits
mailing list