MCPcopy Index your code
hub / github.com/python/cpython / _load_unlocked

Function _load_unlocked

Lib/importlib/_bootstrap.py:841–874  ·  view source on GitHub ↗
(spec)

Source from the content-addressed store, hash-verified

839 return module
840
841def _load_unlocked(spec):
842 # A helper for direct use by the import system.
843 module = module_from_spec(spec)
844
845 # This must be done before putting the module in sys.modules
846 # (otherwise an optimization shortcut in import.c becomes
847 # wrong).
848 spec._initializing = True
849 try:
850 sys.modules[spec.name] = module
851 try:
852 if spec.loader is None:
853 if spec.submodule_search_locations is None:
854 raise ImportError('missing loader', name=spec.name)
855 # A namespace package so do nothing.
856 else:
857 spec.loader.exec_module(module)
858 except:
859 try:
860 del sys.modules[spec.name]
861 except KeyError:
862 pass
863 raise
864 # Move the module to the end of sys.modules.
865 # We don't ensure that the import-related module attributes get
866 # set in the sys.modules replacement case. Such modules are on
867 # their own.
868 module = sys.modules.pop(spec.name)
869 sys.modules[spec.name] = module
870 _verbose_message('import {!r} # {!r}', spec.name, spec.loader)
871 finally:
872 spec._initializing = False
873
874 return module
875
876# A method used during testing of _load_unlocked().
877def _load(spec):

Callers 3

_loadFunction · 0.85
_find_and_load_unlockedFunction · 0.85
_builtin_from_nameFunction · 0.85

Calls 4

module_from_specFunction · 0.85
_verbose_messageFunction · 0.85
exec_moduleMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…