From 92dc2cbb98eb0819237f501e679a28ad0860a57f Mon Sep 17 00:00:00 2001 From: Pavel Koneski Date: Sun, 5 Jan 2025 15:48:26 -0800 Subject: [PATCH 1/3] Backport pythongh-109928: Fix test_mmap.test_access_parameter() on macOS 14 --- Src/StdLib/Lib/test/test_mmap.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Src/StdLib/Lib/test/test_mmap.py b/Src/StdLib/Lib/test/test_mmap.py index ca9af3394..76122c81b 100644 --- a/Src/StdLib/Lib/test/test_mmap.py +++ b/Src/StdLib/Lib/test/test_mmap.py @@ -242,10 +242,15 @@ def test_access_parameter(self): # 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_WRITE 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... From bdc0484bcb3695760bb641e64ddb9fb70dff2a3e Mon Sep 17 00:00:00 2001 From: Pavel Koneski Date: Sun, 5 Jan 2025 15:50:44 -0800 Subject: [PATCH 2/3] Backport pythongh-110125: Fix test_mmap PROT_EXEC comment --- Src/StdLib/Lib/test/test_mmap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/StdLib/Lib/test/test_mmap.py b/Src/StdLib/Lib/test/test_mmap.py index 76122c81b..c63bd48a5 100644 --- a/Src/StdLib/Lib/test/test_mmap.py +++ b/Src/StdLib/Lib/test/test_mmap.py @@ -245,7 +245,7 @@ def test_access_parameter(self): try: m = mmap.mmap(f.fileno(), mapsize, prot=prot) except PermissionError: - # on macOS 14, PROT_READ | PROT_WRITE is not allowed + # on macOS 14, PROT_READ | PROT_EXEC is not allowed pass else: self.assertRaises(TypeError, m.write, b"abcdef") From c9a1896d2fb33a95ad100d577f1958f54420dea9 Mon Sep 17 00:00:00 2001 From: slozier Date: Sun, 5 Jan 2025 20:47:18 -0500 Subject: [PATCH 3/3] Add backport comment --- Src/StdLib/Lib/test/test_mmap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/StdLib/Lib/test/test_mmap.py b/Src/StdLib/Lib/test/test_mmap.py index c63bd48a5..eff2f4295 100644 --- a/Src/StdLib/Lib/test/test_mmap.py +++ b/Src/StdLib/Lib/test/test_mmap.py @@ -242,6 +242,7 @@ def test_access_parameter(self): # 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: + # try/except backported from Python 3.12 try: m = mmap.mmap(f.fileno(), mapsize, prot=prot) except PermissionError: