#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index c060e61..28b52a9 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -462,11 +462,11 @@
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')