You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that it doesn't implement precisely the semantics described in the
version of the PEP posted in July, as some of those ideas didn't prove
feasible due to the fact that imp.new_module can't tell the difference
between normal modules and packages.
An updated version of the PEP will be posted shortly to correct those
problems.
I think the implementation is fine too (others will have to check it
more carefully) but I noticed that the promised functionality of -m
doesn't work yet: I created a file Lib/test/foo.py whose sole contents
was "from . import test_support". Then I tried to import this using
-m:
$ ./python.exe -m test.foo
Traceback (most recent call last):
File "/Users/guido/p/Lib/runpy.py", line 104, in _run_module_as_main
"__main__", fname, loader)
File "/Users/guido/p/Lib/runpy.py", line 34, in _run_code
exec code in run_globals
File "/Users/guido/p/Lib/test/foo.py", line 1, in <module>
from . import test_support
ValueError: Attempted relative import in non-package
$
I forgot to update the special _run_module_as_main variant when I
modified run_module. I'll modify the patch to fix that and to test '-m'
explicitly in test_cmd_line_script.
Posted v2 of the patch, which fixes the problem Guido noted, and
improved the tests to make sure __package__ is being set correctly.
There's also now an explicit test for using -m on a module inside a
package (which proved harder to write than I expected - it isn't easy to
fiddle with sys.path when the subprocess is running python with the -E
flag!).
Posted v2 of the patch, which fixes the problem Guido noted, and
improved the tests to make sure __package__ is being set correctly.
There's also now an explicit test for using -m on a module inside a
package (which proved harder to write than I expected - it isn't easy to
fiddle with sys.path when the subprocess is running python with the -E
flag!).
Activity
ncoghlan commentedon Nov 22, 2007
Patch to implement PEP-366.
Note that it doesn't implement precisely the semantics described in the
version of the PEP posted in July, as some of those ideas didn't prove
feasible due to the fact that imp.new_module can't tell the difference
between normal modules and packages.
An updated version of the PEP will be posted shortly to correct those
problems.
gvanrossum commentedon Nov 30, 2007
I think the implementation is fine too (others will have to check it
more carefully) but I noticed that the promised functionality of -m
doesn't work yet: I created a file Lib/test/foo.py whose sole contents
was "from . import test_support". Then I tried to import this using
-m:
What's missing here?
ncoghlan commentedon Dec 2, 2007
I forgot to update the special _run_module_as_main variant when I
modified run_module. I'll modify the patch to fix that and to test '-m'
explicitly in test_cmd_line_script.
ncoghlan commentedon Dec 2, 2007
Posted v2 of the patch, which fixes the problem Guido noted, and
improved the tests to make sure __package__ is being set correctly.
There's also now an explicit test for using -m on a module inside a
package (which proved harder to write than I expected - it isn't easy to
fiddle with sys.path when the subprocess is running python with the -E
flag!).
gvanrossum commentedon Dec 2, 2007
Great, now check it in!
On Dec 2, 2007 6:01 AM, Nick Coghlan <report@bugs.python.org> wrote:
ncoghlan commentedon Dec 3, 2007
Checked in as rev 59288.