Skip to content

Commit 92dc2cb

Browse files
committed
Backport pythongh-109928: Fix test_mmap.test_access_parameter() on macOS 14
1 parent b6e8595 commit 92dc2cb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Src/StdLib/Lib/test/test_mmap.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,15 @@ 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:
246+
m = mmap.mmap(f.fileno(), mapsize, prot=prot)
247+
except PermissionError:
248+
# on macOS 14, PROT_READ | PROT_WRITE is not allowed
249+
pass
250+
else:
251+
self.assertRaises(TypeError, m.write, b"abcdef")
252+
self.assertRaises(TypeError, m.write_byte, 0)
253+
m.close()
249254

250255
def test_bad_file_desc(self):
251256
# Try opening a bad file descriptor...

0 commit comments

Comments
 (0)