Issue2751
Created on 2008-05-04 00:36 by benjamin.peterson, last changed 2008-05-04 04:34 by ncoghlan.
| msg66184 (view) |
Author: Benjamin Peterson (benjamin.peterson) |
Date: 2008-05-04 00:36 |
|
If I have a package like this:
pack/
__init__.py
and __init__.py looks like this
if __name__ == "__main__":
print "Spam"
python -m pack gives
one is a package and cannot be directly executed
This is regression from 2.5 where "Spam" would be printed.
|
| msg66189 (view) |
Author: Nick Coghlan (ncoghlan) |
Date: 2008-05-04 04:34 |
|
The ability to execute packages was never intended, since doing so
breaks imports in a variety of subtle ways. It was actually a bug in 2.5
that it was permitted at all, so 2.6 not only disabled it again, but
also added a test to make sure it stays disabled (2.4 correctly rejected
it with an ImportError, just as 2.6 does).
Here's the relevant svn log entry:
r56509 | nick.coghlan | 2007-07-23 23:41:45 +1000 (Mon, 23 Jul 2007) | 5
lines
Correctly cleanup sys.modules after executing runpy relative import
tests
Restore Python 2.4 ImportError when attempting to execute a package
(as imports cannot be guaranteed to work properly if you try it)
|
|
| Date |
User |
Action |
Args |
| 2008-05-04 04:34:26 | ncoghlan | set | status: open -> closed resolution: invalid messages:
+ msg66189 |
| 2008-05-04 00:40:15 | benjamin.peterson | set | assignee: ncoghlan nosy:
+ ncoghlan |
| 2008-05-04 00:36:17 | benjamin.peterson | create | |
|