]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154260: Fix test_flush_parameters on DragonFly BSD (GH-154261)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 20 Jul 2026 14:22:51 +0000 (17:22 +0300)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2026 14:22:51 +0000 (14:22 +0000)
DragonFly, like FreeBSD, rejects mmap.flush() with MS_ASYNC|MS_INVALIDATE
(EINVAL).  Use str.startswith() so the check also matches DragonFly, whose
sys.platform carries a version suffix.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Lib/test/test_mmap.py

index 5be9dfac2f5a76feb87efe2f0edad19c423d7d5d..55c6ad04d44d8287984759017308f28b18115938 100644 (file)
@@ -1176,8 +1176,8 @@ class MmapTests(unittest.TestCase):
             if hasattr(mmap, 'MS_INVALIDATE'):
                 m.flush(PAGESIZE * 2, flags=mmap.MS_INVALIDATE)
             if hasattr(mmap, 'MS_ASYNC') and hasattr(mmap, 'MS_INVALIDATE'):
-                if sys.platform == 'freebsd':
-                    # FreeBSD doesn't support this combination
+                if sys.platform.startswith(('freebsd', 'dragonfly')):
+                    # FreeBSD and DragonFly don't support this combination
                     with self.assertRaises(OSError) as cm:
                         m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE)
                     self.assertEqual(cm.exception.errno, errno.EINVAL)