MCPcopy Index your code
hub / github.com/RustPython/RustPython / module_from_spec

Function module_from_spec

Lib/importlib/_bootstrap.py:809–823  ·  view source on GitHub ↗

Create a module based on the provided spec.

(spec)

Source from the content-addressed store, hash-verified

807
808
809def module_from_spec(spec):
810 """Create a module based on the provided spec."""
811 # Typically loaders will not implement create_module().
812 module = None
813 if hasattr(spec.loader, 'create_module'):
814 # If create_module() returns `None` then it means default
815 # module creation should be used.
816 module = spec.loader.create_module(spec)
817 elif hasattr(spec.loader, 'exec_module'):
818 raise ImportError('loaders that define exec_module() '
819 'must also define create_module()')
820 if module is None:
821 module = _new_module(spec.name)
822 _init_module_attrs(spec, module)
823 return module
824
825
826def _module_repr_from_spec(spec):

Callers 1

_load_unlockedFunction · 0.70

Calls 4

hasattrFunction · 0.85
_new_moduleFunction · 0.70
_init_module_attrsFunction · 0.70
create_moduleMethod · 0.45

Tested by

no test coverage detected