Skip to content

Commit

Permalink
gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (#109928)
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Sep 26, 2023
1 parent 9abba71 commit 9dbfe2d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,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...
Expand Down

1 comment on commit 9dbfe2d

@smontanaro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. Will it be backported to 3.12?

Please sign in to comment.