diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 589049f..3c7c2f4 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -14,7 +14,6 @@ services: - /tmp - /judger_run:exec,mode=777 - /spj:exec,mode=777 - - /dev/shm:mode=777 volumes: - $PWD/tests/test_case:/test_case:ro - $PWD/log:/log diff --git a/server/.python-version b/server/.python-version new file mode 100644 index 0000000..b727628 --- /dev/null +++ b/server/.python-version @@ -0,0 +1 @@ +3.6.2 diff --git a/server/compiler.py b/server/compiler.py index c9b0c4f..b88af56 100644 --- a/server/compiler.py +++ b/server/compiler.py @@ -34,7 +34,7 @@ class Compiler(object): if result["result"] != _judger.RESULT_SUCCESS: if os.path.exists(compiler_out): - with open(compiler_out) as f: + with open(compiler_out, encoding="utf-8") as f: error = f.read().strip() os.remove(compiler_out) if error: diff --git a/server/judge_client.py b/server/judge_client.py index 758dc98..1b88dd2 100644 --- a/server/judge_client.py +++ b/server/judge_client.py @@ -56,7 +56,7 @@ class JudgeClient(object): def _compare_output(self, test_case_file_id): user_output_file = os.path.join(self._submission_dir, str(test_case_file_id) + ".out") - with open(user_output_file, "r") as f: + with open(user_output_file, "r", encoding="utf-8") as f: content = f.read() output_md5 = hashlib.md5(content.rstrip().encode("utf-8")).hexdigest() result = output_md5 == self._get_test_case_file_info(test_case_file_id)["stripped_output_md5"] @@ -141,7 +141,7 @@ class JudgeClient(object): if self._output: try: - with open(user_output_file, "r") as f: + with open(user_output_file, "r", encoding="utf-8") as f: run_result["output"] = f.read() except Exception: pass diff --git a/server/server.py b/server/server.py index 3d4a38d..c4fe300 100644 --- a/server/server.py +++ b/server/server.py @@ -66,7 +66,7 @@ class JudgeServer: src_path = os.path.join(submission_dir, compile_config["src_name"]) # write source code into file - with open(src_path, "w") as f: + with open(src_path, "w", encoding="utf-8") as f: f.write(src) # compile source code, return exe file path @@ -75,7 +75,7 @@ class JudgeServer: output_dir=submission_dir) else: exe_path = os.path.join(submission_dir, run_config["exe_name"]) - with open(exe_path, "w") as f: + with open(exe_path, "w", encoding="utf-8") as f: f.write(src) judge_client = JudgeClient(run_config=language_config["run"], @@ -100,7 +100,7 @@ class JudgeServer: # if spj source code not found, then write it into file if not os.path.exists(spj_src_path): - with open(spj_src_path, "w") as f: + with open(spj_src_path, "w", encoding="utf-8") as f: f.write(src) try: Compiler().compile(compile_config=spj_compile_config, diff --git a/tests/test_case/unicode/1.in b/tests/test_case/unicode/1.in new file mode 100644 index 0000000..98882f7 --- /dev/null +++ b/tests/test_case/unicode/1.in @@ -0,0 +1 @@ +你好,世界 diff --git a/tests/test_case/unicode/1.out b/tests/test_case/unicode/1.out new file mode 100644 index 0000000..98882f7 --- /dev/null +++ b/tests/test_case/unicode/1.out @@ -0,0 +1 @@ +你好,世界 diff --git a/tests/test_case/unicode/info b/tests/test_case/unicode/info new file mode 100644 index 0000000..cdee612 --- /dev/null +++ b/tests/test_case/unicode/info @@ -0,0 +1,12 @@ +{ + "spj": false, + "test_cases": { + "1": { + "stripped_output_md5": "dbefd3ada018615b35588a01e216ae6e", + "input_size": 16, + "output_size": 16, + "input_name": "1.in", + "output_name": "1.out" + } + } +} \ No newline at end of file