File tree 1 file changed +8
-1
lines changed
USACOBench/evaluation/judges
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,14 @@ def unsafe_execute():
107
107
check_program = prefix_program + program + suffix_program
108
108
109
109
try :
110
- exec_globals = {}
110
+ # Since we are executing untrusted code we want to remove all global
111
+ # variables from the namespace we provide to "exec" for running this code, but
112
+ # we do want to set the {'__name__': '__main__'} so that "main" function
113
+ # in the generated code does get called (while all the global variables from
114
+ # the original context are still cleared out),
115
+ # We should consider replacing exec with subprocess so that the code
116
+ # is run in a separate Python interpreter process.
117
+ exec_globals = {'__name__' : '__main__' }
111
118
with swallow_io ():
112
119
with time_limit (timeout ):
113
120
# WARNING
You can’t perform that action at this time.
0 commit comments