| 246 | |
| 247 | |
| 248 | def _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 | |
| 260 | def run_path(path_name, init_globals=None, run_name=None): |
| 261 | """Execute code located at the specified filesystem location. |