Skip to content

Commit a47c25d

Browse files
committed
Merged revisions 88484 via svnmerge from
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 python#10826: Prevent sporadic failure in test_subprocess on Solaris due to open door files. ........
1 parent a16b05b commit a47c25d

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

Lib/test/subprocessdata/fd_status.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33

44
import errno
55
import os
6-
import fcntl
76

87
try:
98
_MAXFD = os.sysconf("SC_OPEN_MAX")
109
except:
1110
_MAXFD = 256
1211

13-
def isopen(fd):
14-
"""Return True if the fd is open, and False otherwise"""
15-
try:
16-
fcntl.fcntl(fd, fcntl.F_GETFD, 0)
17-
except IOError as e:
18-
if e.errno == errno.EBADF:
19-
return False
20-
raise
21-
return True
22-
2312
if __name__ == "__main__":
24-
print(','.join(str(fd) for fd in range(0, _MAXFD) if isopen(fd)))
13+
fds = []
14+
for fd in range(0, _MAXFD):
15+
try:
16+
st = os.fstat(fd)
17+
except OSError as e:
18+
if e.errno == errno.EBADF:
19+
continue
20+
raise
21+
# Ignore Solaris door files
22+
if st.st_mode & 0xF000 != 0xd000:
23+
fds.append(fd)
24+
print(','.join(map(str, fds)))

Lib/test/test_subprocess.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,6 @@ def test_pass_fds(self):
11561156

11571157
open_fds = set()
11581158

1159-
if support.verbose:
1160-
print(" -- maxfd =", subprocess.MAXFD)
1161-
11621159
for x in range(5):
11631160
fds = os.pipe()
11641161
self.addCleanup(os.close, fds[0])
@@ -1173,10 +1170,6 @@ def test_pass_fds(self):
11731170

11741171
remaining_fds = set(map(int, output.split(b',')))
11751172
to_be_closed = open_fds - {fd}
1176-
# Temporary debug output for intermittent failures
1177-
if support.verbose:
1178-
print(" -- fds that should have been closed:", to_be_closed)
1179-
print(" -- fds that remained open:", remaining_fds)
11801173

11811174
self.assertIn(fd, remaining_fds, "fd to be passed not passed")
11821175
self.assertFalse(remaining_fds & to_be_closed,

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Build
2727
- Issue #11268: Prevent Mac OS X Installer failure if Documentation
2828
package had previously been installed.
2929

30+
Tests
31+
-----
32+
33+
- Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
34+
to open door files.
35+
3036

3137
What's New in Python 3.2?
3238
=========================

0 commit comments

Comments
 (0)