Spaces:
Sleeping
Sleeping
Trying something else.
Browse files
restrictedpython_code_eval.py
CHANGED
@@ -407,12 +407,12 @@ ALLOWED_SYS_NAMES = ['maxsize']
|
|
407 |
class AllowListImporter:
|
408 |
def __init__(self, allowed_imports: List[str]):
|
409 |
self.allowed_imports = allowed_imports
|
410 |
-
inner_sys = importlib.__import__('sys')
|
411 |
for key in list(dir(inner_sys)):
|
412 |
if key not in ALLOWED_SYS_NAMES:
|
413 |
delattr(inner_sys, key)
|
414 |
self.inner_sys = inner_sys
|
415 |
-
|
416 |
def __call__(self, name, globals=None, locals=None, fromlist=(), level=0):
|
417 |
if name.startswith('.'):
|
418 |
raise ImportError("Relative imports are not allowed.")
|
|
|
407 |
class AllowListImporter:
|
408 |
def __init__(self, allowed_imports: List[str]):
|
409 |
self.allowed_imports = allowed_imports
|
410 |
+
inner_sys = copy.deepcopy(importlib.__import__('sys'))
|
411 |
for key in list(dir(inner_sys)):
|
412 |
if key not in ALLOWED_SYS_NAMES:
|
413 |
delattr(inner_sys, key)
|
414 |
self.inner_sys = inner_sys
|
415 |
+
|
416 |
def __call__(self, name, globals=None, locals=None, fromlist=(), level=0):
|
417 |
if name.startswith('.'):
|
418 |
raise ImportError("Relative imports are not allowed.")
|