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

Function _add_module

Lib/test/support/import_helper.py:410–421  ·  view source on GitHub ↗
(spec, ispkg, addparent)

Source from the content-addressed store, hash-verified

408
409
410def _add_module(spec, ispkg, addparent):
411 if isinstance(spec, str):
412 name = spec
413 mod = create_module(name, ispkg=ispkg)
414 spec = mod.__spec__
415 else:
416 name = spec.name
417 mod = importlib.util.module_from_spec(spec)
418 sys.modules[name] = mod
419 if addparent is not False and spec.parent:
420 _ensure_module(spec.parent, True, addparent, bool(addparent))
421 return mod
422
423
424def add_module(spec, *, parents=True):

Callers 3

_ensure_moduleFunction · 0.85
add_moduleFunction · 0.85
add_packageFunction · 0.85

Calls 2

create_moduleFunction · 0.85
_ensure_moduleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…