allow safe_import to be called with up to 4 args and check for . in name

This commit is contained in:
Guido van Rossum 1995-03-02 15:30:15 +00:00
parent f16d5fa46f
commit b5f9460556
1 changed files with 3 additions and 1 deletions

View File

@ -59,7 +59,9 @@ copydict(posix.environ, safe_posix.environ)
safe_types = new_module('types') safe_types = new_module('types')
copymodule(types, safe_types) copymodule(types, safe_types)
def safe_import(name): def safe_import(name, globals=None, locals=None, fromlist=None):
if '.' in name:
raise ImportError, "import of dotted names not supported"
if safe_sys.modules.has_key(name): if safe_sys.modules.has_key(name):
return safe_sys.modules[name] return safe_sys.modules[name]
if name in safe_modules: if name in safe_modules: