[pypy-svn] r79011 - in pypy/trunk/pypy/translator/goal: . test2

agaynor at codespeak.net agaynor at codespeak.net
Thu Nov 11 18:16:15 CET 2010


Author: agaynor
Date: Thu Nov 11 18:16:14 2010
New Revision: 79011

Modified:
   pypy/trunk/pypy/translator/goal/app_main.py
   pypy/trunk/pypy/translator/goal/test2/test_app_main.py
Log:
Don't put '' on sys.path when executing a script, only when running the REPL, this behavior now matches CPython.


Modified: pypy/trunk/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/app_main.py	(original)
+++ pypy/trunk/pypy/translator/goal/app_main.py	Thu Nov 11 18:16:14 2010
@@ -326,10 +326,6 @@
         except:
             print >> sys.stderr, "'import site' failed"
 
-    # update sys.path *after* loading site.py, in case there is a
-    # "site.py" file in the script's directory.
-    sys.path.insert(0, '')
-
     if warnoptions:
         sys.warnoptions.append(warnoptions)
         from warnings import _processoptions
@@ -378,6 +374,13 @@
         elif run_stdin:
             # handle the case where no command/filename/module is specified
             # on the command-line.
+
+            # update sys.path *after* loading site.py, in case there is a
+            # "site.py" file in the script's directory. Only run this if we're
+            # executing the interactive prompt, if we're running a script we
+            # put it's directory on sys.path
+            sys.path.insert(0, '')
+
             if go_interactive or sys.stdin.isatty():
                 # If stdin is a tty or if "-i" is specified, we print
                 # a banner and run $PYTHONSTARTUP.

Modified: pypy/trunk/pypy/translator/goal/test2/test_app_main.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/test2/test_app_main.py	(original)
+++ pypy/trunk/pypy/translator/goal/test2/test_app_main.py	Thu Nov 11 18:16:14 2010
@@ -95,6 +95,11 @@
         child.expect('>>> ')
         child.sendline('__name__')
         child.expect("'__main__'")
+        child.expect('>>> ')
+        child.sendline('import sys')
+        child.expect('>>> ')
+        child.sendline("'' in sys.path")
+        child.expect("True")
 
     def test_run_script(self):
         child = self.spawn([demo_script])
@@ -487,9 +492,9 @@
 
         with chdir_and_unset_pythonpath(tmpdir):
             data = self.run(cmdline2, python_flags='-S')
-
         assert data.startswith("some new text\n")
         assert repr(str(tmpdir.join('otherpath'))) in data
+        assert "''" not in data
 
 
 class AppTestAppMain:



More information about the Pypy-commit mailing list