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

Function import_file

Tools/peg_generator/pegen/testutil.py:64–75  ·  view source on GitHub ↗

Import a python module from a path

(full_name: str, path: str)

Source from the content-addressed store, hash-verified

62
63
64def import_file(full_name: str, path: str) -> Any:
65 """Import a python module from a path"""
66
67 spec = importlib.util.spec_from_file_location(full_name, path)
68 assert spec is not None
69 mod = importlib.util.module_from_spec(spec)
70
71 # We assume this is not None and has an exec_module() method.
72 # See https://docs.python.org/3/reference/import.html?highlight=exec_module#loading
73 loader = cast(Any, spec.loader)
74 loader.exec_module(mod)
75 return mod
76
77
78def generate_c_parser_source(grammar: Grammar) -> str:

Callers

nothing calls this directly

Calls 2

castFunction · 0.90
exec_moduleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…