mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
Issue #19946: Raise ImportError when the main module cannot be found
by multiprocessing.spawn (before it was raising an AttributeError).
This commit is contained in:
parent
774b2e0af2
commit
ca7ab7c7f1
2 changed files with 5 additions and 0 deletions
|
@ -248,6 +248,8 @@ def import_main_path(main_path):
|
|||
main_module = types.ModuleType(main_name)
|
||||
# XXX Use a target of main_module?
|
||||
spec = importlib.find_spec(main_name, path=dirs)
|
||||
if spec is None:
|
||||
raise ImportError(name=main_name)
|
||||
methods = importlib._bootstrap._SpecMethods(spec)
|
||||
methods.init_module_attrs(main_module)
|
||||
main_module.__name__ = '__mp_main__'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue