[Python-checkins] cpython (3.2): Close #12230: Mac OS X Tiger (10.4) has a kernel bug: sometimes, the file
victor.stinner
python-checkins at python.org
Wed Jun 1 13:19:47 CEST 2011
http://hg.python.org/cpython/rev/22457ac2c2df
changeset: 70575:22457ac2c2df
branch: 3.2
parent: 70572:fe610255861d
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed Jun 01 13:13:04 2011 +0200
summary:
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.
Add also requires_mac_ver() decorator to test.support.
files:
Lib/test/support.py | 30 ++++++++++++++++++++++++-
Lib/test/test_subprocess.py | 5 ++++
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -32,7 +32,8 @@
"Error", "TestFailed", "ResourceDenied", "import_module",
"verbose", "use_resources", "max_memuse", "record_original_stdout",
"get_original_stdout", "unload", "unlink", "rmtree", "forget",
- "is_resource_enabled", "requires", "find_unused_port", "bind_port",
+ "is_resource_enabled", "requires", "requires_mac_ver",
+ "find_unused_port", "bind_port",
"fcmp", "is_jython", "TESTFN", "HOST", "FUZZ", "SAVEDCWD", "temp_cwd",
"findfile", "sortdict", "check_syntax_error", "open_urlresource",
"check_warnings", "CleanImport", "EnvironmentVarGuard",
@@ -288,6 +289,33 @@
msg = "Use of the `%s' resource not enabled" % resource
raise ResourceDenied(msg)
+def requires_mac_ver(*min_version):
+ """Decorator raising SkipTest if the OS is Mac OS X and the OS X
+ version if less than min_version.
+
+ For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
+ is lesser than 10.5.
+ """
+ def decorator(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kw):
+ if sys.platform == 'darwin':
+ version_txt = platform.mac_ver()[0]
+ try:
+ version = tuple(map(int, version_txt.split('.')))
+ except ValueError:
+ pass
+ else:
+ 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'
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1185,6 +1185,11 @@
"Some fds were left open")
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):
fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list