Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
fix: Fix file encoding issues in setup.py and test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Antares0982 committed Mar 30, 2024
1 parent 28e3290 commit d5436da
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def find_src():
extra_link_args=["-lstdc++", "-lm"] + strip_flags,
)

with open("src/version_template.h") as f:
with open("src/version_template.h", encoding='utf-8') as f:
version_template = f.read()


Expand Down
4 changes: 2 additions & 2 deletions test/benchmark_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_benchmark_encode(self):

for filename in bench_files:
base_name = os.path.basename(filename)
with open(filename, "r") as f:
with open(filename, "r", encoding='utf-8') as f:
data = json.load(f)
time_std = self.time_benchmark(1000, json.dumps, data, indent=None, ensure_ascii=False)
print(f"test encode, file: {base_name}, time_std: {time_std}")
Expand All @@ -45,7 +45,7 @@ def test_benchmark_decode(self):

for filename in bench_files:
base_name = os.path.basename(filename)
with open(filename, "r") as f:
with open(filename, "r", encoding='utf-8') as f:
data = f.read()
time_std = self.time_benchmark(1000, json.loads, data)
print(f"test decode, file: {base_name}, time_std: {time_std}")
Expand Down
2 changes: 1 addition & 1 deletion test/decode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_decode(self):

test_cases = [json.dumps(case, ensure_ascii=False) for case in test_cases_origin]
for bench_file in bench_files:
with open(bench_file, "r") as f:
with open(bench_file, "r", encoding='utf-8') as f:
test_cases.append(f.read())

for case in test_cases:
Expand Down
2 changes: 1 addition & 1 deletion test/encode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_encode(self):
]

for file in self._get_benchfiles_fullpath():
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
test_cases.append(json.load(f))

for case in test_cases:
Expand Down
2 changes: 1 addition & 1 deletion test/memory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_decode_leak(self):

datas = []
for file in self._get_benchfiles_fullpath():
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
datas.append(f.read())

# warm up. CPython will not release memory immediately.
Expand Down

0 comments on commit d5436da

Please sign in to comment.