Mailing List Archive

python/dist/src/Lib/test test_mmap.py,1.23,1.24
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv29682/Lib/test

Modified Files:
test_mmap.py
Log Message:
SF bug # 585792, Invalid mmap crashes Python interpreter

Raise ValueError if user passes a size to mmap which is larger
than the file.


Index: test_mmap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** test_mmap.py 23 Jul 2002 19:03:57 -0000 1.23
--- test_mmap.py 5 Sep 2002 21:48:06 -0000 1.24
***************
*** 190,193 ****
--- 190,208 ----
"Readonly memory map data file was modified")

+ print " Opening mmap with size too big"
+ import sys
+ f = open(TESTFN, "r+b")
+ try:
+ m = mmap.mmap(f.fileno(), mapsize+1)
+ except ValueError:
+ # we do not expect a ValueError on Windows
+ if sys.platform.startswith('win'):
+ verify(0, "Opening mmap with size+1 should work on Windows.")
+ pass
+ else:
+ # we expect a ValueError on Unix, but not on Windows
+ if not sys.platform.startswith('win'):
+ verify(0, "Opening mmap with size+1 should raise ValueError.")
+
print " Opening mmap with access=ACCESS_WRITE"
f = open(TESTFN, "r+b")