Allow calling get_frozen_object without paths, raise ImportError when it cant find module

This commit is contained in:
Batuhan Taskaya 2019-10-29 10:51:54 +03:00
parent 82689e1aa8
commit 20d6407aa5
1 changed files with 6 additions and 2 deletions

View File

@ -60,11 +60,15 @@ def find_module(module, paths=None):
return file, path, (suffix, mode, kind)
def get_frozen_object(module, paths):
def get_frozen_object(module, paths=None):
spec = importlib.util.find_spec(module, paths)
return spec.loader.get_code(_resolve(module))
if not spec:
raise ImportError("Can't find %s" % module)
return spec.loader.get_code(module)
def get_module(module, paths, info):
spec = importlib.util.find_spec(module, paths)
if not spec:
raise ImportError("Can't find %s" % module)
return module_from_spec(spec)