[pypy-svn] pypy default: make sure that we insert '' in sys.path also when running with -m, as cpython does.
antocuni
commits-noreply at bitbucket.org
Thu Feb 24 10:13:26 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r42254:da5639f83041
Date: 2011-02-24 10:12 +0100
http://bitbucket.org/pypy/pypy/changeset/da5639f83041/
Log: make sure that we insert '' in sys.path also when running with -m,
as cpython does. Thanks Ademan for the original bug report
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -507,6 +507,8 @@
success = run_toplevel(run_it)
elif run_module:
# handle the "-m" command
+ # '' on sys.path is required also here
+ sys.path.insert(0, '')
import runpy
success = run_toplevel(runpy._run_module_as_main, sys.argv[0])
elif run_stdin:
diff --git a/pypy/translator/goal/test2/test_app_main.py b/pypy/translator/goal/test2/test_app_main.py
--- a/pypy/translator/goal/test2/test_app_main.py
+++ b/pypy/translator/goal/test2/test_app_main.py
@@ -435,6 +435,8 @@
child.expect('True')
child.sendline('"pypy.translator.goal.test2.mymodule" in sys.modules')
child.expect('False')
+ child.sendline('sys.path[0]')
+ child.expect("''")
def test_option_i_noexit(self):
child = self.spawn(['-i', '-c', 'import sys; sys.exit(1)'])
More information about the Pypy-commit
mailing list