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

Method find_spec

Lib/importlib/_bootstrap.py:1048–1075  ·  view source on GitHub ↗
(cls, fullname, path=None, target=None)

Source from the content-addressed store, hash-verified

1046
1047 @classmethod
1048 def find_spec(cls, fullname, path=None, target=None):
1049 info = _call_with_frames_removed(_imp.find_frozen, fullname)
1050 if info is None:
1051 return None
1052 # We get the marshaled data in exec_module() (the loader
1053 # part of the importer), instead of here (the finder part).
1054 # The loader is the usual place to get the data that will
1055 # be loaded into the module. (For example, see _LoaderBasics
1056 # in _bootstrap_external.py.) Most importantly, this importer
1057 # is simpler if we wait to get the data.
1058 # However, getting as much data in the finder as possible
1059 # to later load the module is okay, and sometimes important.
1060 # (That's why ModuleSpec.loader_state exists.) This is
1061 # especially true if it avoids throwing away expensive data
1062 # the loader would otherwise duplicate later and can be done
1063 # efficiently. In this case it isn't worth it.
1064 _, ispkg, origname = info
1065 spec = spec_from_loader(fullname, cls,
1066 origin=cls._ORIGIN,
1067 is_package=ispkg)
1068 filename, pkgdir = cls._resolve_filename(origname, fullname, ispkg)
1069 spec.loader_state = type(sys.implementation)(
1070 filename=filename,
1071 origname=origname,
1072 )
1073 if pkgdir:
1074 spec.submodule_search_locations.insert(0, pkgdir)
1075 return spec
1076
1077 @staticmethod
1078 def create_module(spec):

Callers 2

entry_okMethod · 0.45
_builtin_from_nameFunction · 0.45

Calls 4

spec_from_loaderFunction · 0.85
_resolve_filenameMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected