Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 88229) +++ Misc/NEWS (working copy) @@ -16,6 +16,10 @@ 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 #10989: Fix a crash on SSLContext.load_verify_locations(None, True). - Issue #11020: Command-line pyclbr was broken because of missing 2-to-3 Index: Lib/multiprocessing/forking.py =================================================================== --- Lib/multiprocessing/forking.py (revision 88229) +++ Lib/multiprocessing/forking.py (working copy) @@ -459,12 +459,20 @@ 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: