diff -r a3bdbe220f8a Lib/multiprocessing/spawn.py --- a/Lib/multiprocessing/spawn.py Tue Dec 10 14:06:18 2013 +0200 +++ b/Lib/multiprocessing/spawn.py Wed Dec 11 10:50:29 2013 +0100 @@ -232,6 +232,7 @@ # contain additional code that should still be executed import importlib import types + import imp if main_path is None: dirs = None @@ -248,6 +249,15 @@ 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: + # This can happen for source scripts that do not have the '.py' + # extension under POSIX system. Force loading the module from the + # source file in that case + imp.load_source(main_name, main_path) + spec = importlib.find_spec(main_name, path=dirs) + if spec is None: + raise RuntimeError("Failed to load main module %s from %s" + % (main_name, main_path)) methods = importlib._bootstrap._SpecMethods(spec) methods.init_module_attrs(main_module) main_module.__name__ = '__mp_main__'