[pypy-svn] r40824 - in pypy/dist/pypy/translator/goal: . test2

arigo at codespeak.net arigo at codespeak.net
Tue Mar 20 12:38:26 CET 2007


Author: arigo
Date: Tue Mar 20 12:38:25 2007
New Revision: 40824

Modified:
   pypy/dist/pypy/translator/goal/app_main.py
   pypy/dist/pypy/translator/goal/test2/test_app_main.py
Log:
Forgot to handle the case of the PYTHONINSPECT env var.


Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/app_main.py	Tue Mar 20 12:38:25 2007
@@ -253,6 +253,9 @@
         if hasattr(signal, "SIGPIPE"):
             signal.signal(signal.SIGPIPE, signal.SIG_IGN)
 
+    def is_interactive():
+        return go_interactive or os.getenv('PYTHONINSPECT')
+
     success = True
 
     try:
@@ -267,7 +270,7 @@
                 runpy.run_module(sys.argv[0], None, '__main__', True)
             success = run_toplevel(run_it)
         elif run_stdin:
-            if go_interactive or sys.stdin.isatty():
+            if is_interactive() or sys.stdin.isatty():
                 print_banner()
                 python_startup = os.getenv('PYTHONSTARTUP')
                 if python_startup:
@@ -295,7 +298,7 @@
             sys.path.insert(0, scriptdir)
             success = run_toplevel(execfile, sys.argv[0], mainmodule.__dict__)
             
-        if go_interactive or os.getenv('PYTHONINSPECT'):
+        if is_interactive():
             success = run_toplevel(interactive_console, mainmodule)
     except SystemExit, e:
         return e.code

Modified: pypy/dist/pypy/translator/goal/test2/test_app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/test2/test_app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/test2/test_app_main.py	Tue Mar 20 12:38:25 2007
@@ -246,6 +246,20 @@
         data = os.read(pipe.stdout.fileno(), 1024)
         assert data.startswith('Python')
 
+    def test_options_u_PYTHONINSPECT(self):
+        import subprocess, select, os
+        python = sys.executable
+        pipe = subprocess.Popen([python, app_main, "-u"],
+                                stdout=subprocess.PIPE,
+                                stdin=subprocess.PIPE,
+                                stderr=subprocess.STDOUT,
+                                bufsize=0, close_fds=True,
+                                env={'PYTHONINSPECT': '1'})
+        iwtd, owtd, ewtd = select.select([pipe.stdout], [], [], 5)
+        assert iwtd    # else we timed out
+        data = os.read(pipe.stdout.fileno(), 1024)
+        assert data.startswith('Python')
+
 
 class TestNonInteractive:
 



More information about the Pypy-commit mailing list