(error=ImportError)
| 227 | return _run_code(code, {}, init_globals, run_name, mod_spec) |
| 228 | |
| 229 | def _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 | |
| 248 | def _get_code_from_file(fname, module): |
no test coverage detected
searching dependent graphs…