From 987efbcba6e9976d1351a35454a62d6b8305009d Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 11 Jan 2017 23:46:26 +0530 Subject: check_answer executed in custom scope instead of globals --- yaksh/hook_evaluator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py index 891192c..3956da1 100644 --- a/yaksh/hook_evaluator.py +++ b/yaksh/hook_evaluator.py @@ -53,8 +53,10 @@ class HookEvaluator(BaseEvaluator): try: tb = None _tests = compile(self.hook_code, '', mode='exec') - exec(_tests, globals()) - success, err, mark_fraction = check_answer(self.user_answer) + hook_scope = {} + exec(_tests, hook_scope) + check = hook_scope["check_answer"] + success, err, mark_fraction = check(self.user_answer) except TimeoutException: raise except Exception: -- cgit