This is an archive of the discontinued LLVM Phabricator instance.

[opt-viewer] Decode HTML bytes for Python 3
ClosedPublic

Authored by modocache on Aug 11 2017, 10:41 AM.

Details

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.

Event Timeline

modocache created this revision.Aug 11 2017, 10:41 AM
anemet accepted this revision.Aug 11 2017, 11:01 AM

LGTM, with the same note here: as long as it still works with Python2 (which I am less sure of in this case).

This revision is now accepted and ready to land.Aug 11 2017, 11:01 AM

I double-checked this diff worked when run on a directory containing a single YAML file, using Python 2, and it appeared to work. Let me know if it breaks anything for any of your workflows!

modocache closed this revision.Aug 11 2017, 11:06 AM

This change introduced a regression for python2, which is being fixed by D38289
It would be really nice to get some review there..