Spaces:
Sleeping
Sleeping
Improved how I update additional globals
Browse files
restrictedpython_code_eval.py
CHANGED
@@ -343,7 +343,16 @@ def _unsafe_execute(check_program, result, timeout,
|
|
343 |
builtins.update(utility_builtins)
|
344 |
|
345 |
exec_globals = {'__builtins__': builtins}
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
|
348 |
if allowed_imports is not None:
|
349 |
if '__import__' in exec_globals['__builtins__']:
|
|
|
343 |
builtins.update(utility_builtins)
|
344 |
|
345 |
exec_globals = {'__builtins__': builtins}
|
346 |
+
|
347 |
+
if additional_globals is None:
|
348 |
+
additional_globals = {}
|
349 |
+
|
350 |
+
for key, glob in additional_globals.items():
|
351 |
+
if key not in exec_globals:
|
352 |
+
exec_globals[key] = glob
|
353 |
+
|
354 |
+
else:
|
355 |
+
exec_globals[key].update(glob)
|
356 |
|
357 |
if allowed_imports is not None:
|
358 |
if '__import__' in exec_globals['__builtins__']:
|