summaryrefslogtreecommitdiff
path: root/yaksh/python_assertion_evaluator.py
diff options
context:
space:
mode:
authorankitjavalkar2016-09-21 15:07:43 +0530
committerankitjavalkar2016-09-30 10:33:42 +0530
commitac8d6720bc75676e05462cc38ad144d5aedc14e7 (patch)
treee2e527e159a0704ecdaa2f15ae13900f4555ea63 /yaksh/python_assertion_evaluator.py
parent6b08e56fe3cf70ffbcbd1ed432dde25babe48148 (diff)
downloadonline_test-ac8d6720bc75676e05462cc38ad144d5aedc14e7.tar.gz
online_test-ac8d6720bc75676e05462cc38ad144d5aedc14e7.tar.bz2
online_test-ac8d6720bc75676e05462cc38ad144d5aedc14e7.zip
Migrate python code server and evaluators to python 2/3 compatible
Diffstat (limited to 'yaksh/python_assertion_evaluator.py')
-rw-r--r--yaksh/python_assertion_evaluator.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index 1b66fd2..78154a3 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -1,13 +1,14 @@
#!/usr/bin/env python
+from __future__ import absolute_import
import sys
import traceback
import os
from os.path import join
import importlib
-# local imports
-from code_evaluator import CodeEvaluator, TimeoutException
-from file_utils import copy_files, delete_files
+# Local imports
+from .code_evaluator import CodeEvaluator, TimeoutException
+from .file_utils import copy_files, delete_files
class PythonAssertionEvaluator(CodeEvaluator):
@@ -32,7 +33,7 @@ class PythonAssertionEvaluator(CodeEvaluator):
else:
submitted = compile(user_answer, '<string>', mode='exec')
self.exec_scope = {}
- exec submitted in self.exec_scope
+ exec(submitted, self.exec_scope)
return self.exec_scope
def check_code(self, user_answer, file_paths, test_case):
@@ -40,7 +41,7 @@ class PythonAssertionEvaluator(CodeEvaluator):
try:
tb = None
_tests = compile(test_case, '<string>', mode='exec')
- exec _tests in self.exec_scope
+ exec(_tests, self.exec_scope)
except AssertionError:
type, value, tb = sys.exc_info()
info = traceback.extract_tb(tb)