diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2011-01-30 01:24:08 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2011-01-30 01:24:08 (GMT) |
commit | 793ee1f8a826d93b1f0243644fbf2b1b185eb96b (patch) | |
tree | 609c8582a76fad966eaaf0a15b764967741d5942 | |
parent | c7bb159acd330c3dfb299eebe3340bbdd18bdd85 (diff) | |
download | cpython-793ee1f8a826d93b1f0243644fbf2b1b185eb96b.zip cpython-793ee1f8a826d93b1f0243644fbf2b1b185eb96b.tar.gz cpython-793ee1f8a826d93b1f0243644fbf2b1b185eb96b.tar.bz2 |
Issue #10845: Improve compatibility between multiprocessing on Windows and package, zipfile and directory execution (Reviewed by Antoine Pitrou and approved by Georg Brandl)
-rw-r--r-- | Lib/multiprocessing/forking.py | 10 | ||||
-rw-r--r-- | Misc/NEWS | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py index d2a3208..8ddddb6 100644 --- a/Lib/multiprocessing/forking.py +++ b/Lib/multiprocessing/forking.py @@ -459,12 +459,20 @@ def prepare(data): process.ORIGINAL_DIR = data['orig_dir'] if 'main_path' in data: + # XXX (ncoghlan): The following code makes several bogus + # assumptions regarding the relationship between __file__ + # and a module's real name. See PEP 302 and issue #10845 main_path = data['main_path'] main_name = os.path.splitext(os.path.basename(main_path))[0] if main_name == '__init__': main_name = os.path.basename(os.path.dirname(main_path)) - if main_name != 'ipython': + if main_name == '__main__': + main_module = sys.modules['__main__'] + main_module.__file__ = main_path + elif main_name != 'ipython': + # Main modules not actually called __main__.py may + # contain additional code that should still be executed import imp if main_path is None: @@ -16,6 +16,10 @@ Core and Builtins Library ------- +- Issue #10845: Mitigate the incompatibility between the multiprocessing + module on Windows and the use of package, zipfile or directory execution + by special casing main modules that actually *are* called __main__.py. + - Issue #11045: Protect logging call against None argument. - Issue #11052: Correct IDLE menu accelerators on Mac OS X for Save |