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

Function _get_main_module_details

Lib/runpy.py:229–245  ·  view source on GitHub ↗
(error=ImportError)

Source from the content-addressed store, hash-verified

227 return _run_code(code, {}, init_globals, run_name, mod_spec)
228
229def _get_main_module_details(error=ImportError):
230 # Helper that gives a nicer error message when attempting to
231 # execute a zipfile or directory by invoking __main__.py
232 # Also moves the standard __main__ out of the way so that the
233 # preexisting __loader__ entry doesn't cause issues
234 main_name = "__main__"
235 saved_main = sys.modules[main_name]
236 del sys.modules[main_name]
237 try:
238 return _get_module_details(main_name)
239 except ImportError as exc:
240 if main_name in str(exc):
241 raise error("can't find %r module in %r" %
242 (main_name, sys.path[0])) from exc
243 raise
244 finally:
245 sys.modules[main_name] = saved_main
246
247
248def _get_code_from_file(fname, module):

Callers 2

_run_module_as_mainFunction · 0.85
run_pathFunction · 0.85

Calls 3

_get_module_detailsFunction · 0.85
strFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…