Fix encoding error for executing setup.py
This commit fixes where setup.py may have Unicode symbols. In this case, setup.py is passed as a bytestring to avoid guessing the encoding of setup.py (or to assume it is ASCII).
@@ -780,9 +780,12 @@ if __name__ == "__main__":
"""
# with codecs.open(filename, mode="r", encoding="UTF-8") as ins:
# s = ins.read()
- with open(filename, "r") as ins:
- s = ins.read()
- tree = ast.parse(s, filename=filename, mode='exec')
+ with open(filename, "rb") as ins:
+ tree = ast.parse(
+ ins.read(),
+ filename=filename,
+ mode='exec'
+ )
ArchiveFileInstaller.SetupTransformer().visit(tree)
return tree
