From: Antoine Pitrou Date: Sun, 6 Mar 2011 00:50:56 +0000 (+0100) Subject: Merge fix for issue #11391 X-Git-Tag: v3.2.1b1~344 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80d3610bc36e484fbe7b7ccce366a73314505a16;p=python Merge fix for issue #11391 --- 80d3610bc36e484fbe7b7ccce366a73314505a16 diff --cc Lib/test/test_mmap.py index cbef37441d,0822cc12c3..9b7100d7a2 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@@ -229,11 -231,20 +229,19 @@@ class MmapTests(unittest.TestCase) 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) diff --cc Misc/NEWS index fcbcc882a9,9531d908c3..0b5b74b937 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -31,10 -37,10 +31,14 @@@ Core and Builtin 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().