[pypy-svn] r64715 - pypy/trunk/pypy/module/posix

pedronis at codespeak.net pedronis at codespeak.net
Mon Apr 27 10:11:44 CEST 2009


Author: pedronis
Date: Mon Apr 27 10:11:42 2009
New Revision: 64715

Modified:
   pypy/trunk/pypy/module/posix/app_posix.py
Log:
minimal fix for os.popen on windows (not tried)

Modified: pypy/trunk/pypy/module/posix/app_posix.py
==============================================================================
--- pypy/trunk/pypy/module/posix/app_posix.py	(original)
+++ pypy/trunk/pypy/module/posix/app_posix.py	Mon Apr 27 10:11:42 2009
@@ -154,6 +154,8 @@
             raise Exception, e     # bare 'raise' does not work here :-(
 
 else:
+    # Windows implementations
+    
     # Supply os.popen() based on subprocess
     def popen(cmd, mode="r", bufsize=-1):
         """popen(command [, mode='r' [, bufsize]]) -> pipe
@@ -165,18 +167,22 @@
         if not mode.startswith('r') and not mode.startswith('w'):
             raise ValueError("invalid mode %r" % (mode,))
 
+        univ_nl = ('b' not in mode)
+
         import subprocess
         if mode.startswith('r'):
             proc = subprocess.Popen(cmd,
                                     shell=True,
                                     stdout=subprocess.PIPE,
-                                    bufsize=bufsize)
+                                    bufsize=bufsize,
+                                    universal_newlines=univ_nl)
             return _wrap_close(proc.stdout, proc)
         else:
             proc = subprocess.Popen(cmd,
                                     shell=True,
                                     stdin=subprocess.PIPE,
-                                    bufsize=bufsize)
+                                    bufsize=bufsize,
+                                    universal_newlines=univ_nl)
             return _wrap_close(proc.stdin, proc)
 
     def popen2(cmd, mode="t", bufsize=-1):



More information about the Pypy-commit mailing list