Author ncoghlan
Recipients benjamin.peterson, ncoghlan
Date 2008-10-13.09:20:12
SpamBayes Score 9.99201e-16
Marked as misclassified No
Message-id <1223889614.96.0.899217049351.issue2751@psf.upfronthosting.co.za>
In-reply-to
Content
(Adding some additional details regarding the reasons why this became an
error again in 2.6)

The ImportError when attempting to execute a package was lost during the
conversion from the C-based implementation in 2.4 to the runpy module
based implementation as part of 2.5. Packages really aren't meant to be
executable with -m - it gets messy since__init__ is able to modify the
way module lookups work within the package, and there are various other
package specific details related to relative imports that don't apply
when dealing with normal modules.

That said, executing "-m pkg.__init__" with Python 2.6 will generally
have the same effect as doing "-m pkg" with Python 2.5 (it keeps the
import machinery happy since the package gets imported normally first,
and so long as pkg.__init__ can cope with being first imported normally
for the package initialisation and then run as '__main__' it should also
work as a script).

Anyone that would like to see the ability to execute packages restored
should feel free to create a RFE issue for it, but it would take a
fairly detailed analysis of the import system to convince me that doing
so doesn't break any of the interpreter internals.
History
Date User Action Args
2008-10-13 09:20:15ncoghlansetrecipients: + ncoghlan, benjamin.peterson
2008-10-13 09:20:14ncoghlansetmessageid: <1223889614.96.0.899217049351.issue2751@psf.upfronthosting.co.za>
2008-10-13 09:20:14ncoghlanlinkissue2751 messages
2008-10-13 09:20:12ncoghlancreate