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()
+ with open(TESTFN, "rb") as f :
+ self.assertRaisesRegex(ValueError,
+ "cannot mmap an empty file",
+ mmap.mmap, f.fileno(), 0,
+ access=mmap.ACCESS_READ)
def test_offset (self):
f = open (TESTFN, 'w+b')
}
size = (((PY_LONG_LONG) high) << 32) + low;
+ if (size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "cannot mmap an empty file");
+ return NULL;
+ }
if (offset >= size) {
PyErr_SetString(PyExc_ValueError,
"mmap offset is greater than file size");