From 99f0c944fafec51b9327fe5dea01096842788e03 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 4 Jul 2018 16:34:56 +0530 Subject: Raise appropriate exceptions for C and Java language to the Grader - Raise AssertionError,CompilationError and TestCaseError for assertion, user answer compilation and testcase compilation errors respectively. - Add test case for C/C++ and Java --- yaksh/grader.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'yaksh/grader.py') diff --git a/yaksh/grader.py b/yaksh/grader.py index 320e7e7..de8f897 100644 --- a/yaksh/grader.py +++ b/yaksh/grader.py @@ -23,6 +23,13 @@ class TimeoutException(Exception): pass +class CompilationError(Exception): + pass + + +class TestCaseError(Exception): + pass + @contextlib.contextmanager def change_dir(path): cur_dir = abspath(dirname(MY_DIR)) -- cgit From ec0903e00ffab1f0f0e6e674637243cd6a548115 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 4 Jul 2018 17:07:01 +0530 Subject: Make pep8 changes --- yaksh/grader.py | 1 + 1 file changed, 1 insertion(+) (limited to 'yaksh/grader.py') diff --git a/yaksh/grader.py b/yaksh/grader.py index de8f897..c8356f3 100644 --- a/yaksh/grader.py +++ b/yaksh/grader.py @@ -30,6 +30,7 @@ class CompilationError(Exception): class TestCaseError(Exception): pass + @contextlib.contextmanager def change_dir(path): cur_dir = abspath(dirname(MY_DIR)) -- cgit From 0b2980148288b44571820e1176dea0e2dffcec81 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Fri, 6 Jul 2018 14:04:48 +0530 Subject: Fix unicode issue in grader --- yaksh/grader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'yaksh/grader.py') diff --git a/yaksh/grader.py b/yaksh/grader.py index c8356f3..c1be493 100644 --- a/yaksh/grader.py +++ b/yaksh/grader.py @@ -167,10 +167,14 @@ class Grader(object): line_no = traceback.extract_tb(exc_tb)[-1][1] if len(tb_list) > 2: del tb_list[1:3] + try: + exc_value = str(exc_value) + except UnicodeEncodeError: + exc_value = unicode(exc_value) error.append( prettify_exceptions( - exc_type.__name__, str(exc_value), "".join(tb_list), - line_no=line_no + exc_type.__name__, exc_value, + "".join(tb_list), line_no=line_no ) ) finally: -- cgit