Commit 456fe5d3 authored by Guido van Rossum's avatar Guido van Rossum

Fix a weird use of try/finally to close a file.

(There are more places that don't close 'f' at all if an error occurs,
but none have a bogus try/finally pattern.)
parent b358a2c4
......@@ -29,6 +29,7 @@ class MmapTests(unittest.TestCase):
f.write(b'\0'* (PAGESIZE-3) )
f.flush()
m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
finally:
f.close()
# Simple sanity checks
......@@ -97,19 +98,15 @@ class MmapTests(unittest.TestCase):
# Check that the underlying file is truncated too
# (bug #728515)
f = open(TESTFN)
try:
f.seek(0, 2)
self.assertEqual(f.tell(), 512)
finally:
f.close()
self.assertEqual(m.size(), 512)
m.close()
finally:
try:
f.close()
except OSError:
pass
def test_access_parameter(self):
# Test for "access" keyword parameter
mapsize = 10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment