python: Use UTF-8 encodings for opened files
This commit is contained in:
parent
434f32151c
commit
c592bf7da0
|
@ -418,7 +418,7 @@ class RPCCoverage(object):
|
|||
if not os.path.isfile(coverage_ref_filename):
|
||||
raise RuntimeError("No coverage reference found")
|
||||
|
||||
with open(coverage_ref_filename, 'r') as f:
|
||||
with open(coverage_ref_filename, 'r', encoding='utf8') as f:
|
||||
all_cmds.update([i.strip() for i in f.readlines()])
|
||||
|
||||
for root, dirs, files in os.walk(self.dir):
|
||||
|
@ -427,7 +427,7 @@ class RPCCoverage(object):
|
|||
coverage_filenames.add(os.path.join(root, filename))
|
||||
|
||||
for filename in coverage_filenames:
|
||||
with open(filename, 'r') as f:
|
||||
with open(filename, 'r', encoding='utf8') as f:
|
||||
covered_cmds.update([i.strip() for i in f.readlines()])
|
||||
|
||||
return all_cmds - covered_cmds
|
||||
|
|
|
@ -107,7 +107,7 @@ class GitHubToken:
|
|||
def __init__(self):
|
||||
token_path = os.path.join(SOURCE_ROOT, ".updatecheck-token")
|
||||
try:
|
||||
with open(token_path) as f:
|
||||
with open(token_path, encoding='utf8') as f:
|
||||
token = f.read().strip()
|
||||
self._user = token.split(":")[0]
|
||||
self._password = token.split(":")[1]
|
||||
|
|
|
@ -39,7 +39,7 @@ def bctest(testDir, testObj, exeext):
|
|||
inputData = None
|
||||
if "input" in testObj:
|
||||
filename = testDir + "/" + testObj['input']
|
||||
inputData = open(filename).read()
|
||||
inputData = open(filename, encoding='utf8').read()
|
||||
stdinCfg = subprocess.PIPE
|
||||
|
||||
# Read the expected output data (if there is any)
|
||||
|
@ -49,7 +49,7 @@ def bctest(testDir, testObj, exeext):
|
|||
outputFn = testObj['output_cmp']
|
||||
outputType = os.path.splitext(outputFn)[1][1:] # output type from file extension (determines how to compare)
|
||||
try:
|
||||
outputData = open(testDir + "/" + outputFn).read()
|
||||
outputData = open(testDir + "/" + outputFn, encoding='utf8').read()
|
||||
except:
|
||||
logging.error("Output file " + outputFn + " can not be opened")
|
||||
raise
|
||||
|
@ -105,7 +105,7 @@ def bctest(testDir, testObj, exeext):
|
|||
def bctester(testDir, input_basename, buildenv):
|
||||
""" Loads and parses the input file, runs all tests and reports results"""
|
||||
input_filename = testDir + "/" + input_basename
|
||||
raw_data = open(input_filename).read()
|
||||
raw_data = open(input_filename, encoding='utf8').read()
|
||||
input_data = json.loads(raw_data)
|
||||
|
||||
failed_testcases = []
|
||||
|
|
Loading…
Reference in New Issue