Commit d64c780f authored by Victor Stinner's avatar Victor Stinner

(Merge 3.2) Close #12230: Mac OS X Tiger (10.4) has a kernel bug: sometimes,

the file descriptor of a pipe closed in the parent process is valid in the
child process according to fstat(), but the mode of the file descriptor is
invalid, and read or write raise an error.

test.support.requires_mac_ver() is now a decorator, as suggested by Ezio
Melotti, and its docstring is fixed (linux_version => mac_ver).
parents 7da567f7 fe6cadb1
...@@ -301,23 +301,32 @@ def linux_version(): ...@@ -301,23 +301,32 @@ def linux_version():
return 0, 0, 0 return 0, 0, 0
def requires_mac_ver(*min_version): def requires_mac_ver(*min_version):
"""Raise SkipTest if the OS is Mac OS X and the OS X version if less than """Decorator raising SkipTest if the OS is Mac OS X and the OS X
min_version. version if less than min_version.
For example, support.requires_linux_version(10, 5) raises SkipTest if the For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
version is less than 10.5. is lesser than 10.5.
""" """
if sys.platform != 'darwin': def decorator(func):
return @functools.wraps(func)
version_txt = platform.mac_ver()[0] def wrapper(*args, **kw):
try: if sys.platform == 'darwin':
version = tuple(map(int, version_txt.split('.'))) version_txt = platform.mac_ver()[0]
except ValueError: try:
return version = tuple(map(int, version_txt.split('.')))
if version < min_version: except ValueError:
min_version_txt = '.'.join(map(str, min_version)) pass
raise unittest.SkipTest("Mac OS X %s or higher required, not %s" else:
% (min_version_txt, version_txt)) if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
"Mac OS X %s or higher required, not %s"
% (min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
HOST = 'localhost' HOST = 'localhost'
......
...@@ -670,10 +670,9 @@ class MathTests(unittest.TestCase): ...@@ -670,10 +670,9 @@ class MathTests(unittest.TestCase):
self.assertTrue(math.isnan(math.log2(NAN))) self.assertTrue(math.isnan(math.log2(NAN)))
@requires_IEEE_754 @requires_IEEE_754
# log2() is not accurate enough on Mac OS X Tiger (10.4)
@support.requires_mac_ver(10, 5)
def testLog2Exact(self): def testLog2Exact(self):
# log2() is not accurate enough on Mac OS X Tiger (10.4)
support.requires_mac_ver(10, 5)
# Check that we get exact equality for log2 of powers of 2. # Check that we get exact equality for log2 of powers of 2.
actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)] actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
expected = [float(n) for n in range(-1074, 1024)] expected = [float(n) for n in range(-1074, 1024)]
......
...@@ -1281,6 +1281,11 @@ class POSIXProcessTestCase(BaseTestCase): ...@@ -1281,6 +1281,11 @@ class POSIXProcessTestCase(BaseTestCase):
"Some fds were left open") "Some fds were left open")
self.assertIn(1, remaining_fds, "Subprocess failed") self.assertIn(1, remaining_fds, "Subprocess failed")
# Mac OS X Tiger (10.4) has a kernel bug: sometimes, the file
# descriptor of a pipe closed in the parent process is valid in the
# child process according to fstat(), but the mode of the file
# descriptor is invalid, and read or write raise an error.
@support.requires_mac_ver(10, 5)
def test_pass_fds(self): def test_pass_fds(self):
fd_status = support.findfile("fd_status.py", subdir="subprocessdata") fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment