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

Function _gcd_import

Lib/importlib/_bootstrap.py:1305–1317  ·  view source on GitHub ↗

Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes setting __package__ if the loader did not.

(name, package=None, level=0)

Source from the content-addressed store, hash-verified

1303
1304
1305def _gcd_import(name, package=None, level=0):
1306 """Import and return the module based on its name, the package the call is
1307 being made from, and the level adjustment.
1308
1309 This function represents the greatest common denominator of functionality
1310 between import_module and __import__. This includes setting __package__ if
1311 the loader did not.
1312
1313 """
1314 _sanity_check(name, package, level)
1315 if level > 0:
1316 name = _resolve_name(name, package, level)
1317 return _find_and_load(name, _gcd_import)
1318
1319
1320def _handle_fromlist(module, fromlist, import_, *, recursive=False):

Callers 1

__import__Function · 0.85

Calls 3

_sanity_checkFunction · 0.85
_resolve_nameFunction · 0.85
_find_and_loadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…