OSDN Git Service

[opt-viewer] Decode HTML bytes for Python 3
authorBrian Gesiak <modocache@gmail.com>
Fri, 11 Aug 2017 18:05:26 +0000 (18:05 +0000)
committerBrian Gesiak <modocache@gmail.com>
Fri, 11 Aug 2017 18:05:26 +0000 (18:05 +0000)
commit6ab329730630774179c22d7ef07a4b9a18c6686f
tree8cf50f71a2348e91c580fc3b420b11ad6a7bfc8f
parentb5a17e3f73755e2be4fd9332552a73782efc660c
[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
tools/opt-viewer/opt-viewer.py