mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 11:33:46 +02:00
Explicitly specify encoding when opening text files in Python code
This commit is contained in:
@@ -28,7 +28,7 @@ import sys
|
||||
def main():
|
||||
config = configparser.ConfigParser()
|
||||
config.optionxform = str
|
||||
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini")))
|
||||
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
|
||||
env_conf = dict(config.items('environment'))
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
@@ -49,7 +49,7 @@ def main():
|
||||
def bctester(testDir, input_basename, buildenv):
|
||||
""" Loads and parses the input file, runs all tests and reports results"""
|
||||
input_filename = os.path.join(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 = []
|
||||
@@ -86,7 +86,7 @@ def bctest(testDir, testObj, buildenv):
|
||||
inputData = None
|
||||
if "input" in testObj:
|
||||
filename = os.path.join(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)
|
||||
@@ -97,7 +97,7 @@ def bctest(testDir, testObj, buildenv):
|
||||
outputFn = testObj['output_cmp']
|
||||
outputType = os.path.splitext(outputFn)[1][1:] # output type from file extension (determines how to compare)
|
||||
try:
|
||||
outputData = open(os.path.join(testDir, outputFn)).read()
|
||||
outputData = open(os.path.join(testDir, outputFn), encoding="utf8").read()
|
||||
except:
|
||||
logging.error("Output file " + outputFn + " can not be opened")
|
||||
raise
|
||||
|
Reference in New Issue
Block a user