diff options
author | Jesus Cea <jcea@jcea.es> | 2012-09-10 20:49:50 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-09-10 20:49:50 (GMT) |
commit | 1f2799bef45673419e96ad4ef6a923c59d1c6a85 (patch) | |
tree | f69d47f2609cb35b8e38c6e0e557ac432ced6c0f /Lib/test | |
parent | 3159cb51a77da430272bfaf42c768493c72b456a (diff) | |
download | cpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.zip cpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.tar.gz cpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.tar.bz2 |
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_mmap.py | 10 |
1 files changed, 5 insertions, 5 deletions
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 @@ class MmapTests(unittest.TestCase): 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') |