Commits

Amaury Forgeot d'Arc committed 5e8ec66

Fixes in _posixsubprocess module.

Comments (0)

Files changed (2)

pypy/module/_posixsubprocess/interp_subprocess.py

     threadsafe=True)
 c_cloexec_pipe = rffi.llexternal(
     'pypy_subprocess_cloexec_pipe',
-    [rffi.CArrayPtr(rffi.LONG)], rffi.INT,
+    [rffi.CArrayPtr(rffi.INT)], rffi.INT,
     compilation_info=eci,
     threadsafe=True)     
     
     # These conversions are done in the parent process to avoid allocating
     # or freeing memory in the child process.
     try:
-        exec_array = [space.bytes_w(w_item)
+        exec_array = [space.bytes0_w(w_item)
                       for w_item in space.listview(w_executable_list)]
         l_exec_array = rffi.liststr2charpp(exec_array)
 
             l_argv = rffi.liststr2charpp(argv)
 
         if not space.is_none(w_env_list):
-            envp = [space.bytes_w(w_item)
+            envp = [space.bytes0_w(w_item)
                     for w_item in space.listview(w_env_list)]
             l_envp = rffi.liststr2charpp(envp)
 
     """"cloexec_pipe() -> (read_end, write_end)
     Create a pipe whose ends have the cloexec flag set."""
 
-    with lltype.scoped_alloc(rffi.CArrayPtr(rffi.LONG).TO, 2) as fds:
+    with lltype.scoped_alloc(rffi.CArrayPtr(rffi.INT).TO, 2) as fds:
         res = c_cloexec_pipe(fds)
         if res != 0:
             raise exception_from_errno(space, space.w_OSError)

pypy/module/_posixsubprocess/test/test_subprocess.py

+class AppTestSubprocess:
+    spaceconfig = dict(usemodules=('_posixsubprocess',))
+
+    # XXX write more tests
+
+    def test_cloexec_pipe(self):
+        import _posixsubprocess, os
+        fd1, fd2 = _posixsubprocess.cloexec_pipe()
+        # Sanity checks
+        assert 0 <= fd1 < 4096
+        assert 0 <= fd2 < 4096
+        os.close(fd1)
+        os.close(fd2)