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/instructions_extractor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'kpov_judge/instructions_extractor.py') diff --git a/kpov_judge/instructions_extractor.py b/kpov_judge/instructions_extractor.py index b1644b2..f747c1a 100644 --- a/kpov_judge/instructions_extractor.py +++ b/kpov_judge/instructions_extractor.py @@ -22,8 +22,9 @@ def print_instructions(p, fname): print(" - ".join(l1)) with open(os.path.join(p, fname)) as f: task_code = compile(f.read(), fname, 'exec') - exec(task_code) - for lang, text in instructions.items(): + d = {} + exec(task_code, globals(), d) + for lang, text in d['instructions'].items(): print("Language: {0}".format(lang)) print(text.encode('utf-8')) print("") -- cgit v1.2.1