Charles-François Natali <neolo...@free.fr> added the comment:
> @requires_freebsd_version should be factorized with
> @requires_linux_version.
Patches attached.
> Can we workaround FreeBSD (< 8) bug in C/Python?
Not really.
> Or should we remove the function on FreeBSD < 8?
There's really no reason to do that (and it's really a minor bug).
----------
Added file: http://bugs.python.org/file23296/freebsd_msgtrunc-1.diff
Added file: http://bugs.python.org/file23297/requires_unix_version.diff
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13001>
_______________________________________
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1659,6 +1659,9 @@
def _testRecvmsgShorter(self):
self.sendToServer(MSG)
+ # FreeBSD < 8 doesn't always set the MSG_TRUNC flag when a truncated
+ # datagram is received (issue #13001).
+ @support.requires_freebsd_version(8)
def testRecvmsgTrunc(self):
# Receive part of message, check for truncation indicators.
msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
@@ -1668,6 +1671,7 @@
self.assertEqual(ancdata, [])
self.checkFlags(flags, eor=False)
+ @support.requires_freebsd_version(8)
def _testRecvmsgTrunc(self):
self.sendToServer(MSG)
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -44,8 +44,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", "requires_linux_version",
- "requires_mac_ver", "find_unused_port", "bind_port",
+ "is_resource_enabled", "requires", "requires_freebsd_version",
+ "requires_linux_version", "requires_mac_ver", "find_unused_port",
"bind_port",
"IPV6_ENABLED", "is_jython", "TESTFN", "HOST", "SAVEDCWD", "temp_cwd",
"findfile", "create_empty_file", "sortdict", "check_syntax_error",
"open_urlresource",
"check_warnings", "CleanImport", "EnvironmentVarGuard",
"TransientResource",
@@ -312,17 +312,17 @@
msg = "Use of the %r resource not enabled" % resource
raise ResourceDenied(msg)
-def requires_linux_version(*min_version):
- """Decorator raising SkipTest if the OS is Linux and the kernel version is
- less than min_version.
+def _requires_unix_version(sysname, min_version):
+ """Decorator raising SkipTest if the OS is `sysname` and the version is
less
+ than `min_version`.
- For example, @requires_linux_version(2, 6, 35) raises SkipTest if the Linux
- kernel version is less than 2.6.35.
+ For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
+ the FreeBSD version is less than 7.2.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
- if sys.platform == 'linux':
+ if platform.system() == sysname:
version_txt = platform.release().split('-', 1)[0]
try:
version = tuple(map(int, version_txt.split('.')))
@@ -332,13 +332,29 @@
if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
- "Linux kernel %s or higher required, not %s"
- % (min_version_txt, version_txt))
- return func(*args, **kw)
- wrapper.min_version = min_version
+ "%s version %s or higher required, not %s"
+ % (sysname, min_version_txt, version_txt))
return wrapper
return decorator
+def requires_freebsd_version(*min_version):
+ """Decorator raising SkipTest if the OS is FreeBSD and the FreeBSD version
is
+ less than `min_version`.
+
+ For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD
+ version is less than 7.2.
+ """
+ return _requires_unix_version('FreeBSD', min_version)
+
+def requires_linux_version(*min_version):
+ """Decorator raising SkipTest if the OS is Linux and the Linux version is
+ less than `min_version`.
+
+ For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux
+ version is less than 2.6.32.
+ """
+ return _requires_unix_version('Linux', min_version)
+
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.
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com