]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 2 Oct 2023 10:09:54 +0000 (03:09 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 10:09:54 +0000 (12:09 +0200)
gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928)
(cherry picked from commit 9dbfe2dc8e7bba25e52f9470ae6969821a365297)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_mmap.py

index bab868600895c1c2bb437816da082b09d3f19d8c..dfcf3039422af5e0d0328c2b1c5d022a4a3d6a02 100644 (file)
@@ -255,10 +255,15 @@ class MmapTests(unittest.TestCase):
             # Try writing with PROT_EXEC and without PROT_WRITE
             prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
             with open(TESTFN, "r+b") as f:
-                m = mmap.mmap(f.fileno(), mapsize, prot=prot)
-                self.assertRaises(TypeError, m.write, b"abcdef")
-                self.assertRaises(TypeError, m.write_byte, 0)
-                m.close()
+                try:
+                    m = mmap.mmap(f.fileno(), mapsize, prot=prot)
+                except PermissionError:
+                    # on macOS 14, PROT_READ | PROT_EXEC is not allowed
+                    pass
+                else:
+                    self.assertRaises(TypeError, m.write, b"abcdef")
+                    self.assertRaises(TypeError, m.write_byte, 0)
+                    m.close()
 
     def test_bad_file_desc(self):
         # Try opening a bad file descriptor...