MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_main_module_details

Function _get_main_module_details

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

Source from the content-addressed store, hash-verified

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

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