Index: llvm/trunk/tools/opt-viewer/opt-viewer.py =================================================================== --- llvm/trunk/tools/opt-viewer/opt-viewer.py +++ llvm/trunk/tools/opt-viewer/opt-viewer.py @@ -10,6 +10,7 @@ import os.path import re import shutil +import sys from pygments import highlight from pygments.lexers.c_cpp import CppLexer @@ -62,7 +63,11 @@ html_highlighted = highlight( file_text, self.cpp_lexer, - self.html_formatter).decode('utf-8') + self.html_formatter) + + # On Python 3, pygments.highlight() returns a bytes object, not a str. + if sys.version_info >= (3, 0): + html_highlighted = html_highlighted.decode('utf-8') # Take off the header and footer, these must be # reapplied line-wise, within the page structure