diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 16:05:39 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 16:05:39 (GMT) |
commit | b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00 (patch) | |
tree | b38661db4903b7edc4042e7562b32720dd3687bf /Lib/multiprocessing/spawn.py | |
parent | 9e6097ebe7bb99a4a22b949ef4b1563b21ad7166 (diff) | |
download | cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.zip cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.tar.gz cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.tar.bz2 |
Implement PEP 451 (ModuleSpec).
Diffstat (limited to 'Lib/multiprocessing/spawn.py')
-rw-r--r-- | Lib/multiprocessing/spawn.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py index 8167454..364b53f 100644 --- a/Lib/multiprocessing/spawn.py +++ b/Lib/multiprocessing/spawn.py @@ -245,14 +245,13 @@ def import_main_path(main_path): # We should not try to load __main__ # since that would execute 'if __name__ == "__main__"' # clauses, potentially causing a psuedo fork bomb. - loader = importlib.find_loader(main_name, path=dirs) main_module = types.ModuleType(main_name) - try: - loader.init_module_attrs(main_module) - except AttributeError: # init_module_attrs is optional - pass + # XXX Use a target of main_module? + spec = importlib.find_spec(main_name, path=dirs) + methods = importlib._bootstrap._SpecMethods(spec) + methods.init_module_attrs(main_module) main_module.__name__ = '__mp_main__' - code = loader.get_code(main_name) + code = spec.loader.get_code(main_name) exec(code, main_module.__dict__) old_main_modules.append(sys.modules['__main__']) |