Skip to content

Commit 719a446

Browse files
BCSharpslozier
andauthored
Backport fixes to python/cpython#107888 (#1865)
* Backport pythongh-109928: Fix test_mmap.test_access_parameter() on macOS 14 * Backport pythongh-110125: Fix test_mmap PROT_EXEC comment * Add backport comment --------- Co-authored-by: slozier <[email protected]>
1 parent b6e8595 commit 719a446

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Src/StdLib/Lib/test/test_mmap.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,16 @@ def test_access_parameter(self):
242242
# Try writing with PROT_EXEC and without PROT_WRITE
243243
prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
244244
with open(TESTFN, "r+b") as f:
245-
m = mmap.mmap(f.fileno(), mapsize, prot=prot)
246-
self.assertRaises(TypeError, m.write, b"abcdef")
247-
self.assertRaises(TypeError, m.write_byte, 0)
248-
m.close()
245+
# try/except backported from Python 3.12
246+
try:
247+
m = mmap.mmap(f.fileno(), mapsize, prot=prot)
248+
except PermissionError:
249+
# on macOS 14, PROT_READ | PROT_EXEC is not allowed
250+
pass
251+
else:
252+
self.assertRaises(TypeError, m.write, b"abcdef")
253+
self.assertRaises(TypeError, m.write_byte, 0)
254+
m.close()
249255

250256
def test_bad_file_desc(self):
251257
# Try opening a bad file descriptor...

0 commit comments

Comments
 (0)