]> granicus.if.org Git - python/commitdiff
Merged revisions 88484 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 21 Feb 2011 21:58:42 +0000 (21:58 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 21 Feb 2011 21:58:42 +0000 (21:58 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88484 | antoine.pitrou | 2011-02-21 22:55:48 +0100 (lun., 21 févr. 2011) | 4 lines

  Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
  to open door files.
........

Lib/test/subprocessdata/fd_status.py
Lib/test/test_subprocess.py
Misc/NEWS

index 083b2f9ec550cef38ff7b39e467406722c49d4ae..1f61e13a345626a3d3b47b8c2765ab0ac3dac8d4 100644 (file)
@@ -3,22 +3,22 @@ file descriptors on stdout."""
 
 import errno
 import os
-import fcntl
 
 try:
     _MAXFD = os.sysconf("SC_OPEN_MAX")
 except:
     _MAXFD = 256
 
-def isopen(fd):
-    """Return True if the fd is open, and False otherwise"""
-    try:
-        fcntl.fcntl(fd, fcntl.F_GETFD, 0)
-    except IOError as e:
-        if e.errno == errno.EBADF:
-            return False
-        raise
-    return True
-
 if __name__ == "__main__":
-    print(','.join(str(fd) for fd in range(0, _MAXFD) if isopen(fd)))
+    fds = []
+    for fd in range(0, _MAXFD):
+        try:
+            st = os.fstat(fd)
+        except OSError as e:
+            if e.errno == errno.EBADF:
+                continue
+            raise
+        # Ignore Solaris door files
+        if st.st_mode & 0xF000 != 0xd000:
+            fds.append(fd)
+    print(','.join(map(str, fds)))
index cf6684d816bcd51b8ec792a9d2af16732a98b26e..4b58308497976def800adf5c08f9248e683996d4 100644 (file)
@@ -1156,9 +1156,6 @@ class POSIXProcessTestCase(BaseTestCase):
 
         open_fds = set()
 
-        if support.verbose:
-            print(" -- maxfd =", subprocess.MAXFD)
-
         for x in range(5):
             fds = os.pipe()
             self.addCleanup(os.close, fds[0])
@@ -1173,10 +1170,6 @@ class POSIXProcessTestCase(BaseTestCase):
 
             remaining_fds = set(map(int, output.split(b',')))
             to_be_closed = open_fds - {fd}
-            # Temporary debug output for intermittent failures
-            if support.verbose:
-                print(" -- fds that should have been closed:", to_be_closed)
-                print(" -- fds that remained open:", remaining_fds)
 
             self.assertIn(fd, remaining_fds, "fd to be passed not passed")
             self.assertFalse(remaining_fds & to_be_closed,
index 4d139e8f5ae8cf008259cc66e502aa1e61de6459..f3e73498ac0a925c1a86b1271291c6557924598e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,12 @@ Build
 - Issue #11268: Prevent Mac OS X Installer failure if Documentation
   package had previously been installed.
 
+Tests
+-----
+
+- Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
+  to open door files.
+
 
 What's New in Python 3.2?
 =========================