]> granicus.if.org Git - python/commitdiff
Issue #19946: Raise ImportError when the main module cannot be found
authorBrett Cannon <brett@python.org>
Fri, 13 Dec 2013 16:43:10 +0000 (11:43 -0500)
committerBrett Cannon <brett@python.org>
Fri, 13 Dec 2013 16:43:10 +0000 (11:43 -0500)
by multiprocessing.spawn (before it was raising an AttributeError).

Lib/multiprocessing/spawn.py
Misc/NEWS

index 364b53f499c4514a6b4a61e039c339321f5f0a7f..c3adfc14a82028d8c352e2c2cecfb62ea0a285ba 100644 (file)
@@ -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__'
index f99a0d82f861d98e03ecd088e696b8cd6df654e8..93b9dd6884db65ee008cd58da04339ba6ecd12cf 100644 (file)
--- 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