llvm.org GIT mirror llvm / 6ab3297
[opt-viewer] Decode HTML bytes for Python 3 Summary: When using Python 3, `pygments.highlight()` returns a `bytes` object, not a `str`, causing the call to `str.replace` on the following line to fail with a runtime exception: `TypeError: 'str' does not support the buffer interface`. Decode the bytes into a string in order to fix the exception. Test Plan: Run `opt-viewer.py` with Python 3.4, and confirm no runtime error occurs when calling `str.replace`. Reviewers: anemet Reviewed By: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310741 91177308-0d34-0410-b5e6-96231b3b80d8 Brian Gesiak 2 years ago
1 changed file(s) with 4 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5858
5959 def render_source_lines(self, stream, line_remarks):
6060 file_text = stream.read()
61 html_highlighted = highlight(file_text, self.cpp_lexer, self.html_formatter)
61 html_highlighted = highlight(
62 file_text,
63 self.cpp_lexer,
64 self.html_formatter).decode('utf-8')
6265
6366 # Take off the header and footer, these must be
6467 # reapplied line-wise, within the page structure