Lines Matching refs:code
1 """runpy.py - locating and running Python code using the module namespace
6 This allows Python code to play nicely with non-filesystem based PEP 302
65 def _run_code(code, run_globals, init_globals=None,
68 """Helper to run code in nominated namespace"""
88 exec(code, run_globals)
91 def _run_module_code(code, init_globals=None,
94 """Helper to run code in new namespace with sys modified"""
98 _run_code(code, mod_globals, init_globals,
104 # Helper to get the full name, spec and code for a module
159 code = loader.get_code(mod_name)
162 if code is None:
163 raise error("No code object available for %s" % mod_name)
164 return mod_name, spec, code
178 function should be used to run the module code in a fresh namespace.
189 mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
191 mod_name, mod_spec, code = _get_main_module_details(_Error)
198 return _run_code(code, main_globals, None,
203 """Execute a module's code without importing it.
209 globals dictionary before the code is executed.
222 mod_name, mod_spec, code = _get_module_details(mod_name)
226 return _run_module_code(code, init_globals, run_name, mod_spec)
229 return _run_code(code, {}, init_globals, run_name, mod_spec)
255 code = read_code(f)
256 if code is None:
257 # That didn't work, so try it as normal source code
259 code = compile(f.read(), fname, 'exec')
260 return code, fname
263 """Execute code located at the specified filesystem location.
270 globals dictionary before the code is executed.
288 # Not a valid sys.path entry, so run the code directly
290 code, fname = _get_code_from_file(run_name, path_name)
291 return _run_module_code(code, init_globals, run_name,
300 # code was running and doing so was somewhat optional. Here, we
302 # code. If we don't do this, a __loader__ attribute in the
304 mod_name, mod_spec, code = _get_main_module_details()
308 return _run_code(code, mod_globals, init_globals,