From c3bfe5d5aa557e98b9ab53b8dbe9887c8c80be35 Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 29 Dec 2025 00:36:52 +0900 Subject: [PATCH] gh-63016: fix failing `mmap.flush` tests on FreeBSD (#143230) Fix `mmap.flush` tests introduced in 1af21ea32043ad5bd4eaacd48a1718d4e0bef945 where some flag combinations are not supported on FreeBSD. --- Lib/test/test_mmap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index bc3593ce4ba..48bf246cadd 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1173,7 +1173,13 @@ def test_flush_parameters(self): if hasattr(mmap, 'MS_INVALIDATE'): m.flush(PAGESIZE * 2, flags=mmap.MS_INVALIDATE) if hasattr(mmap, 'MS_ASYNC') and hasattr(mmap, 'MS_INVALIDATE'): - m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE) + if sys.platform == 'freebsd': + # FreeBSD doesn'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) + else: + m.flush(0, PAGESIZE, flags=mmap.MS_ASYNC | mmap.MS_INVALIDATE) @unittest.skipUnless(sys.platform == 'linux', 'Linux only') @support.requires_linux_version(5, 17, 0)