From: Brett Cannon Date: Fri, 13 Dec 2013 16:43:10 +0000 (-0500) Subject: Issue #19946: Raise ImportError when the main module cannot be found X-Git-Tag: v3.4.0b2~231 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca7ab7c7f10f27d8e3df3281c78180802d767358;p=thirdparty%2FPython%2Fcpython.git Issue #19946: Raise ImportError when the main module cannot be found by multiprocessing.spawn (before it was raising an AttributeError). --- diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py index 364b53f499c4..c3adfc14a820 100644 --- a/Lib/multiprocessing/spawn.py +++ b/Lib/multiprocessing/spawn.py @@ -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__' diff --git a/Misc/NEWS b/Misc/NEWS index f99a0d82f861..93b9dd6884db 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,9 @@ Core and Builtins Library ------- +- Issue #19946: multiprocessing.spawn now raises ImportError when the module to + be used as the main module cannot be imported. + - Issue #17919: select.poll.poll() again works with poll.POLLNVAL on AIX. - Issue #19063: if a Charset's body_encoding was set to None, the email