MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _run_module_code

Function _run_module_code

_pydevd_bundle/pydevd_runpy.py:122–130  ·  view source on GitHub ↗

Helper to run code in new namespace with sys modified

(code, init_globals=None, mod_name=None, mod_spec=None, pkg_name=None, script_name=None)

Source from the content-addressed store, hash-verified

120
121
122def _run_module_code(code, init_globals=None, mod_name=None, mod_spec=None, pkg_name=None, script_name=None):
123 """Helper to run code in new namespace with sys modified"""
124 fname = script_name if mod_spec is None else mod_spec.origin
125 with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
126 mod_globals = temp_module.module.__dict__
127 _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
128 # Copy the globals of the temporary module, as they
129 # may be cleared when the temporary module goes away
130 return mod_globals.copy()
131
132
133# Helper to get the full name, spec and code for a module

Callers 2

run_moduleFunction · 0.85
run_pathFunction · 0.85

Calls 4

_TempModuleClass · 0.85
_ModifiedArgv0Class · 0.85
_run_codeFunction · 0.85
copyMethod · 0.80

Tested by

no test coverage detected