Index: Lib/test/test_mmap.py =================================================================== --- Lib/test/test_mmap.py (révision 60801) +++ Lib/test/test_mmap.py (copie de travail) @@ -426,7 +426,14 @@ return mmap.mmap.__new__(klass, -1, *args, **kwargs) anon_mmap(PAGESIZE) + def test_prot_readonly(self): + mapsize = 10 + open(TESTFN, "wb").write("a"*mapsize) + f = open(TESTFN, "rb") + m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ) + self.assertRaises(TypeError, m.write, "foo") + def test_main(): run_unittest(MmapTests) Index: Modules/mmapmodule.c =================================================================== --- Modules/mmapmodule.c (révision 60801) +++ Modules/mmapmodule.c (copie de travail) @@ -1122,6 +1122,10 @@ "mmap invalid access parameter."); } + if (prot == PROT_READ) { + access = ACCESS_READ; + } + #ifdef HAVE_FSTAT # ifdef __VMS /* on OpenVMS we must ensure that all bytes are written to the file */