Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r60921:3863e3e7c3e2
Date: 2013-02-06 21:52 -0500
http://bitbucket.org/pypy/pypy/changeset/3863e3e7c3e2/

Log:    don't use closerange in os.popen (cpython doesn't), add test

diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -140,8 +140,8 @@
 
         Open a pipe to/from a command returning a file object."""
 
-        from subprocess import MAXFD
-        import os, gc
+        import os
+        import gc
 
         def try_close(fd):
             try:
@@ -165,7 +165,6 @@
                         else:
                             os.dup2(read_end, 0)
                             os.close(write_end)
-                        os.closerange(3, MAXFD)
                         cmd = ['/bin/sh', '-c', command]
                         os.execvp(cmd[0], cmd)
                     finally:
diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -14,7 +14,7 @@
 import signal
 
 def setup_module(mod):
-    usemodules = ['binascii', 'posix', 'struct', 'rctime', 'signal', 'select']
+    usemodules = ['binascii', 'posix', 'struct', 'rctime']
     if os.name != 'nt':
         usemodules += ['fcntl']
     else:
@@ -513,6 +513,14 @@
             res = fp.read()
             assert res == '1\n'
 
+    def test_popen_child_fds(self):
+        os = self.posix
+        from os.path import join
+        with open(join(self.pdir, 'file1'), 'r') as fd:
+            with os.popen('%s -c "import os; print os.read(%d, 10)"' % 
(self.python, fd.fileno())) as stream:
+                res = stream.read()
+                assert res == 'test1\n'
+
     if hasattr(__import__(os.name), '_getfullpathname'):
         def test__getfullpathname(self):
             # nt specific
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to