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 ncoghlan
Recipients asksol, brett.cannon, brian.curtin, georg.brandl, jnoller, michael.foord, ncoghlan, pitrou, terry.reedy, vstinner
Date 2011-01-29.14:40:14
SpamBayes Score 2.3812248e-09
Marked as misclassified No
Message-id <1296312016.61.0.227321290687.issue10845@psf.upfronthosting.co.za>
In-reply-to
Content
"Useless" is a rather strong word. Every change we've made to the import system (or, more accurately, the main module identification system) has been backed up with decent use cases - nearly all of the subsequent problems can be traced back to the information that gets thrown away due to the backwards compatibility concerns that forced the main module to always be called "__main__" without any record of its real name.

In the current case, it is the 3-way combination of that behaviour with the lack of real fork() functionality on Windows and an invalid assumption in multiprocessing as to the relationship between __file__ and __name__ that is causing problems.

Back on topic, Antoine's tweak looks very similar to the solution I was working on (although I hadn't made it as far as figuring out the need to change test/__main__.py to skip the execution of the top level code).

Seeing the need for that change, I think the right answer is actually to skip the find_module/load_module call completely when the module is a file called __main__.py. Such modules are implicitly part of a "if __name__ == '__main__'" clause, as that's their whole reason for existence.

The attached patch works along those lines, and I tested it by making the substantive change (the additional if clause) to an installed copy of 3.2rc1 on my Windows gaming rig.
History
Date User Action Args
2011-01-29 14:40:16ncoghlansetrecipients: + ncoghlan, brett.cannon, georg.brandl, terry.reedy, pitrou, vstinner, jnoller, michael.foord, brian.curtin, asksol
2011-01-29 14:40:16ncoghlansetmessageid: <1296312016.61.0.227321290687.issue10845@psf.upfronthosting.co.za>
2011-01-29 14:40:15ncoghlanlinkissue10845 messages
2011-01-29 14:40:15ncoghlancreate