summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-09-09 22:27:55 (GMT)
committerJesus Cea <jcea@jcea.es>2012-09-09 22:27:55 (GMT)
commit941bfcc537a25077e2a73ddf8d8b3bfe288c81f4 (patch)
treeaecc62becfac5c8a9592e021e60be2f3ec862620 /Lib
parent7330da42978ffcde525295ffc928ee3e0eedfb1b (diff)
downloadcpython-941bfcc537a25077e2a73ddf8d8b3bfe288c81f4.zip
cpython-941bfcc537a25077e2a73ddf8d8b3bfe288c81f4.tar.gz
cpython-941bfcc537a25077e2a73ddf8d8b3bfe288c81f4.tar.bz2
Closes #15676: mmap: add empty file check prior to offset check
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_mmap.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 0e18aab..c060e61 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -459,6 +459,15 @@ class MmapTests(unittest.TestCase):
f.flush ()
return mmap.mmap (f.fileno(), 0)
+ def test_empty_file (self):
+ f = open (TESTFN, 'w+b')
+ f.close()
+ f = open(TESTFN, "rb")
+ self.assertRaisesRegex(ValueError,
+ "cannot mmap an empty file",
+ mmap.mmap, f.fileno(), 0, access=mmap.ACCESS_READ)
+ f.close()
+
def test_offset (self):
f = open (TESTFN, 'w+b')