From 772532d87cc97828d1e29c0ca91f50112f5a6ede Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 5 Oct 2018 18:04:45 +0200 Subject: Pass globals() to exec calls --- kpov_judge/web/kpov_judge/kpov_judge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kpov_judge/web') diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 5d3e791..b190567 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -91,7 +91,7 @@ def results_post(class_id, task_id, results): try: task_check_source = db.task_checkers.find_one({'class_id': class_id, 'task_id': task_id})['source'] d = {} - exec(compile(task_check_source, 'checker.py', 'exec'), d) + exec(compile(task_check_source, 'checker.py', 'exec'), globals(), d) # raise Exception(str(params)) res, hints = d['task_check'](results, params) except Exception as e: @@ -188,7 +188,7 @@ def get_params(class_id, task_id, student_id, db): gen_params_source = db.gen_params.find_one({'class_id': class_id, 'task_id': task_id})['source'] gen_params_code = compile(gen_params_source, 'generator.py', 'exec') d = {} - exec(gen_params_code, d) + exec(gen_params_code, globals(), d) params = d['gen_params'](student_id, meta) db.task_params.update({'class_id': class_id, 'task_id': task_id, 'student_id': student_id}, {'$set': {'params': params}}, upsert=True) -- cgit v1.2.1