aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backend/routes/forms/unittesting.py2
-rw-r--r--resources/unittest_template.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/backend/routes/forms/unittesting.py b/backend/routes/forms/unittesting.py
index f7f6072..c00fc4c 100644
--- a/backend/routes/forms/unittesting.py
+++ b/backend/routes/forms/unittesting.py
@@ -98,7 +98,7 @@ async def execute_unittest(form_response: FormResponse, form: Form) -> list[Unit
return_code = int(response["returncode"])
# Another code has been returned by CPython because of another failure.
- if return_code not in (0, 5, 99):
+ if return_code not in (0, 5, 6, 99):
return_code = 99
result = "Internal error."
else:
diff --git a/resources/unittest_template.py b/resources/unittest_template.py
index 755f7cc..02d3894 100644
--- a/resources/unittest_template.py
+++ b/resources/unittest_template.py
@@ -25,6 +25,7 @@ def _exit_sandbox(code: int) -> NoReturn:
Codes:
- 0: Executed with success
- 5: Syntax error while parsing user code
+ - 6: Uncaught exception while loading user code
- 99: Internal error
"""
print(RESULT.getvalue(), file=ORIGINAL_STDOUT, end="")
@@ -74,8 +75,12 @@ try:
sys.stderr = DEVNULL
# Load the user code as a global module variable
- module = _load_user_module()
+ try:
+ module = _load_user_module()
+ except Exception:
+ RESULT.write("Uncaught exception while loading user code.")
+ _exit_sandbox(6)
_main()
except Exception:
- print("Uncaught exception inside runner.", file=RESULT)
- _exit_sandbox(99) \ No newline at end of file
+ RESULT.write("Uncaught exception inside runner.")
+ _exit_sandbox(99)