Skip to content

Commit

Permalink
Merge pull request #4 from aarora79/main
Browse files Browse the repository at this point in the history
enable main() function execution in generated code
  • Loading branch information
benshi34 authored Jan 14, 2025
2 parents e86da8d + e5ac66f commit 46f18c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion USACOBench/evaluation/judges/usaco_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ def unsafe_execute():
check_program = prefix_program + program + suffix_program

try:
exec_globals = {}
# Since we are executing untrusted code we want to remove all global
# variables from the namespace we provide to "exec" for running this code, but
# we do want to set the {'__name__': '__main__'} so that "main" function
# in the generated code does get called (while all the global variables from
# the original context are still cleared out),
# We should consider replacing exec with subprocess so that the code
# is run in a separate Python interpreter process.
exec_globals = {'__name__': '__main__'}
with swallow_io():
with time_limit(timeout):
# WARNING
Expand Down

0 comments on commit 46f18c8

Please sign in to comment.