[Python-checkins] cpython: Issue #19946: Raise ImportError when the main module cannot be found

brett.cannon python-checkins at python.org
Fri Dec 13 17:43:19 CET 2013


http://hg.python.org/cpython/rev/cea42629ddf5
changeset: 87937:cea42629ddf5
user: Brett Cannon <brett at python.org>
date: Fri Dec 13 11:43:10 2013 -0500
summary:
 Issue #19946: Raise ImportError when the main module cannot be found
by multiprocessing.spawn (before it was raising an AttributeError).
files:
 Lib/multiprocessing/spawn.py | 2 ++
 Misc/NEWS | 3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py
--- a/Lib/multiprocessing/spawn.py
+++ b/Lib/multiprocessing/spawn.py
@@ -248,6 +248,8 @@
 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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,9 @@
 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
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /