diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 9c70e18d6a1291..c89ab6e8b576f4 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -29,6 +29,7 @@ import os import re from functools import reduce +from io import open FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") @@ -56,7 +57,7 @@ def GetName(self): def GetCommand(self): result = [self.config.context.GetVm(self.arch, self.mode)] - source = open(self.file).read() + source = open(self.file, encoding='utf8').read() flags_match = FLAGS_PATTERN.search(source) if flags_match: flags = flags_match.group(1).strip().split() diff --git a/tools/test.py b/tools/test.py index 878e2bef35da46..04babded24b590 100755 --- a/tools/test.py +++ b/tools/test.py @@ -45,6 +45,7 @@ import errno import copy +from io import open from os.path import join, dirname, abspath, basename, isdir, exists from datetime import datetime try: @@ -733,8 +734,8 @@ def disableCoreFiles(): ) os.close(fd_out) os.close(fd_err) - output = open(outname).read() - errors = open(errname).read() + output = open(outname, encoding='utf8').read() + errors = open(errname, encoding='utf8').read() CheckedUnlink(outname) CheckedUnlink(errname)