Skip to content

Commit 102db92

Browse files
leduythuccshieplpvip
authored andcommitted
Don't throw InternalError for invalid zip file
Squashed in: - Don't throw InternalError for dmoj checker bridged format
1 parent 0582b20 commit 102db92

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

dmoj/contrib/default.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import Any
1+
from typing import TYPE_CHECKING
22

3-
from dmoj.error import InternalError
3+
from dmoj.contrib.base import BaseContribModule
4+
from dmoj.executors.base_executor import BaseExecutor
45
from dmoj.result import CheckerResult
56
from dmoj.utils.helper_files import parse_helper_file_error
67

@@ -11,21 +12,6 @@
1112
class ContribModule(BaseContribModule):
1213
name = 'default'
1314

14-
def catch_internal_error(f: Any) -> Any:
15-
def wrapper(*args, **kwargs) -> CheckerResult:
16-
try:
17-
return f(*args, **kwargs)
18-
except InternalError as e:
19-
proc = args[1]
20-
return CheckerResult(
21-
False,
22-
0,
23-
feedback=f'Checker exitcode {proc.returncode}',
24-
extended_feedback=str(e),
25-
)
26-
27-
return wrapper
28-
2915
@classmethod
3016
def get_checker_args_format_string(cls) -> str:
3117
return '{input_file} {output_file} {answer_file}'
@@ -35,8 +21,23 @@ def get_interactor_args_format_string(cls) -> str:
3521
return '{input_file} {answer_file}'
3622

3723
@classmethod
24+
def get_validator_args_format_string(cls) -> str:
25+
return '{batch_no} {case_no}'
26+
27+
@classmethod
28+
@BaseContribModule.catch_internal_error
3829
def parse_return_code(
39-
cls, proc, executor, point_value, time_limit, memory_limit, feedback, extended_feedback, name, stderr, **kwargs
30+
cls,
31+
proc: 'TracedPopen',
32+
executor: BaseExecutor,
33+
point_value: float,
34+
time_limit: float,
35+
memory_limit: int,
36+
feedback: str,
37+
extended_feedback: str,
38+
name: str,
39+
stderr: bytes,
40+
**kwargs
4041
):
4142
if proc.returncode == cls.AC:
4243
return CheckerResult(True, point_value, feedback=feedback, extended_feedback=extended_feedback)

dmoj/graders/output_only.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def _interact_with_zipfile(self, result: Result, case: TestCase) -> None:
3535
result.result_flag = Result.OLE
3636
return
3737

38-
result.proc_output = self.zip_file.open(output_name).read()
38+
try:
39+
result.proc_output = self.zip_file.open(output_name).read()
40+
except Exception as e:
41+
result.feedback = f'Invalid output file: {repr(e)}'
42+
result.result_flag = Result.WA
3943

4044
def get_zip_file(self) -> ZipFile:
4145
zip_data = download_source_code(utf8text(self.source).strip(), self.problem.meta.get('file-size-limit', 1))

0 commit comments

Comments
 (0)