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

Function _get_code_from_file

Lib/runpy.py:248–258  ·  view source on GitHub ↗
(fname, module)

Source from the content-addressed store, hash-verified

246
247
248def _get_code_from_file(fname, module):
249 # Check for a compiled file first
250 from pkgutil import read_code
251 code_path = os.path.abspath(fname)
252 with io.open_code(code_path) as f:
253 code = read_code(f)
254 if code is None:
255 # That didn't work, so try it as normal source code
256 with io.open_code(code_path) as f:
257 code = compile(f.read(), fname, 'exec', module=module)
258 return code
259
260def run_path(path_name, init_globals=None, run_name=None):
261 """Execute code located at the specified filesystem location.

Callers 1

run_pathFunction · 0.85

Calls 4

read_codeFunction · 0.90
compileFunction · 0.70
abspathMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…