homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients asksol, brett.cannon, brian.curtin, georg.brandl, jnoller, michael.foord, ncoghlan, pitrou, terry.reedy, vstinner
Date 2011年01月29日.13:29:32
SpamBayes Score 1.6450008e-11
Marked as misclassified No
Message-id <1296307772.82.0.451932606692.issue10845@psf.upfronthosting.co.za>
In-reply-to
Content
Actually, forget that (!). The following patch seems to work:
Index: Lib/multiprocessing/forking.py
===================================================================
--- Lib/multiprocessing/forking.py	(révision 88224)
+++ Lib/multiprocessing/forking.py	(copie de travail)
@@ -474,7 +474,8 @@
 else:
 dirs = [os.path.dirname(main_path)]
 
- assert main_name not in sys.modules, main_name
+ if main_name != '__main__':
+ assert main_name not in sys.modules, main_name
 file, path_name, etc = imp.find_module(main_name, dirs)
 try:
 # We would like to do "imp.load_module('__main__', ...)"
Index: Lib/test/__main__.py
===================================================================
--- Lib/test/__main__.py	(révision 88224)
+++ Lib/test/__main__.py	(copie de travail)
@@ -1,13 +1,16 @@
 from test import regrtest, support
 
+# Issue #10845: avoid executing toplevel code if imported by multiprocessing
+# (which is smart enough to import the module under another name).
+if __name__ == "__main__":
 
-TEMPDIR, TESTCWD = regrtest._make_temp_dir_for_build(regrtest.TEMPDIR)
-regrtest.TEMPDIR = TEMPDIR
-regrtest.TESTCWD = TESTCWD
+ TEMPDIR, TESTCWD = regrtest._make_temp_dir_for_build(regrtest.TEMPDIR)
+ regrtest.TEMPDIR = TEMPDIR
+ regrtest.TESTCWD = TESTCWD
 
-# Run the tests in a context manager that temporary changes the CWD to a
-# temporary and writable directory. If it's not possible to create or
-# change the CWD, the original CWD will be used. The original CWD is
-# available from support.SAVEDCWD.
-with support.temp_cwd(TESTCWD, quiet=True):
- regrtest.main()
+ # Run the tests in a context manager that temporary changes the CWD to a
+ # temporary and writable directory. If it's not possible to create or
+ # change the CWD, the original CWD will be used. The original CWD is
+ # available from support.SAVEDCWD.
+ with support.temp_cwd(TESTCWD, quiet=True):
+ regrtest.main()
History
Date User Action Args
2011年01月29日 13:29:32pitrousetrecipients: + pitrou, brett.cannon, georg.brandl, terry.reedy, ncoghlan, vstinner, jnoller, michael.foord, brian.curtin, asksol
2011年01月29日 13:29:32pitrousetmessageid: <1296307772.82.0.451932606692.issue10845@psf.upfronthosting.co.za>
2011年01月29日 13:29:32pitroulinkissue10845 messages
2011年01月29日 13:29:32pitroucreate

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