Ensure source files are read as utf8, rather than a system-specific encoding.
We authored the files being read here, so we know their encoding in advance.
This fixes a CI failure in Python 3.5.
Also switch to use a `with` statement to ensure the file is closed a little sooner.
@@ -44,7 +44,8 @@ from io import StringIO
from cocotb._build_libs import get_ext, build_ext
def read_file(fname):
- return open(path.join(path.dirname(__file__), fname)).read()
+ with open(path.join(path.dirname(__file__), fname), encoding='utf8') as f:
+ return f.read()
def package_files(directory):
paths = []
