if os.name == "posix":
# Try incompatible flags, prot and access parameters.
- f = open(TESTFN, "r+b")
- self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
- flags=mmap.MAP_PRIVATE,
- prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
- f.close()
+ with open(TESTFN, "r+b") as f:
+ self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
+ flags=mmap.MAP_PRIVATE,
+ prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
+ # 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()
+
def test_bad_file_desc(self):
# Try opening a bad file descriptor...
self.assertRaises(mmap.error, mmap.mmap, -2, 4096)
Library
-------
+ - Issue #11391: Writing to a mmap object created with
+ ``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a
+ TypeError. Patch by Charles-François Natali.
+
+- Issue #11306: mailbox in certain cases adapts to an inability to open
+ certain files in read-write mode. Previously it detected this by
+ checking for EACCES, now it also checks for EROFS.
+
- Issue #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
on accept(), send() and recv().