Commit 6af03fa5 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 a1b4be11
...@@ -29,6 +29,7 @@ class MmapTests(unittest.TestCase): ...@@ -29,6 +29,7 @@ class MmapTests(unittest.TestCase):
f.write(b'\0'* (PAGESIZE-3) ) f.write(b'\0'* (PAGESIZE-3) )
f.flush() f.flush()
m = mmap.mmap(f.fileno(), 2 * PAGESIZE) m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
finally:
f.close() f.close()
# Simple sanity checks # Simple sanity checks
...@@ -97,19 +98,15 @@ class MmapTests(unittest.TestCase): ...@@ -97,19 +98,15 @@ class MmapTests(unittest.TestCase):
# Check that the underlying file is truncated too # Check that the underlying file is truncated too
# (bug #728515) # (bug #728515)
f = open(TESTFN) f = open(TESTFN)
try:
f.seek(0, 2) f.seek(0, 2)
self.assertEqual(f.tell(), 512) self.assertEqual(f.tell(), 512)
finally:
f.close() f.close()
self.assertEqual(m.size(), 512) self.assertEqual(m.size(), 512)
m.close() m.close()
finally:
try:
f.close()
except OSError:
pass
def test_access_parameter(self): def test_access_parameter(self):
# Test for "access" keyword parameter # Test for "access" keyword parameter
mapsize = 10 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