mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
This commit is contained in:
parent
3fb774ec5f
commit
20f0ea1f61
2 changed files with 14 additions and 12 deletions
|
@ -469,18 +469,15 @@ class MmapTests(unittest.TestCase):
|
|||
def test_empty_file (self):
|
||||
f = open (TESTFN, 'w+b')
|
||||
f.close()
|
||||
f = open(TESTFN, "rb")
|
||||
try:
|
||||
m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
m.close()
|
||||
f.close()
|
||||
self.fail("should not have been able to mmap empty file")
|
||||
except ValueError as e:
|
||||
f.close()
|
||||
self.assertEqual(e.message, "cannot mmap an empty file")
|
||||
except:
|
||||
f.close()
|
||||
self.fail("unexpected exception: " + str(e))
|
||||
with open(TESTFN, "rb") as f :
|
||||
try:
|
||||
m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
m.close()
|
||||
self.fail("should not have been able to mmap empty file")
|
||||
except ValueError as e:
|
||||
self.assertEqual(e.message, "cannot mmap an empty file")
|
||||
except:
|
||||
self.fail("unexpected exception: " + str(e))
|
||||
|
||||
def test_offset (self):
|
||||
f = open (TESTFN, 'w+b')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue