[pypy-svn] pypy default: Don't update argv[0] when executing a directory (which contains __main__.py)

amauryfa commits-noreply at bitbucket.org
Mon Mar 7 15:26:57 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r42461:cf9ef708a291
Date: 2011-03-07 15:25 +0100
http://bitbucket.org/pypy/pypy/changeset/cf9ef708a291/

Log:	Don't update argv[0] when executing a directory (which contains
	__main__.py)

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
@@ -593,7 +593,7 @@
                     # the module __main__
                     import runpy
                     sys.path.insert(0, filename)
-                    args = (runpy._run_module_as_main, '__main__')
+                    args = (runpy._run_module_as_main, '__main__', False)
                 else:
                     # no.  That's the normal path, "pypy stuff.py".
                     args = (execfile, filename, mainmodule.__dict__)

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
@@ -542,7 +542,8 @@
         process = subprocess.Popen(
             cmdline,
             stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
-            shell=True, env=env
+            shell=True, env=env,
+            universal_newlines=True
         )
         child_in, child_out_err = process.stdin, process.stdout
         child_in.write(senddata)
@@ -732,11 +733,11 @@
     def test_main_in_dir_commandline_argument(self):
         if not hasattr(runpy, '_run_module_as_main'):
             skip("requires CPython >= 2.6")
-        p = getscript_in_dir('print 6*7\n')
+        p = getscript_in_dir('import sys; print sys.argv[0]\n')
         data = self.run(p)
-        assert data == '42\n'
+        assert data == p + '\n'
         data = self.run(p + os.sep)
-        assert data == '42\n'
+        assert data == p + os.sep + '\n'
 
     def test_pythonioencoding(self):
         if sys.version_info < (2, 7):


More information about the Pypy-commit mailing list