[pypy-commit] pypy default: use a try finally instead
bdkearns
noreply at buildbot.pypy.org
Mon Sep 8 00:24:17 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r73368:596c682e4f53
Date: 2014-09-07 18:22 -0400
http://bitbucket.org/pypy/pypy/changeset/596c682e4f53/
Log: use a try finally instead
diff --git a/lib-python/2.7/test/test_mmap.py b/lib-python/2.7/test/test_mmap.py
--- a/lib-python/2.7/test/test_mmap.py
+++ b/lib-python/2.7/test/test_mmap.py
@@ -179,29 +179,27 @@
import sys
f = open(TESTFN, "r+b")
try:
- m = mmap.mmap(f.fileno(), mapsize+1)
- except ValueError:
- # we do not expect a ValueError on Windows
- # CAUTION: This also changes the size of the file on disk, and
- # later tests assume that the length hasn't changed. We need to
- # repair that.
+ try:
+ m = mmap.mmap(f.fileno(), mapsize+1)
+ except ValueError:
+ # we do not expect a ValueError on Windows
+ # CAUTION: This also changes the size of the file on disk, and
+ # later tests assume that the length hasn't changed. We need to
+ # repair that.
+ if sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should work on Windows.")
+ else:
+ # we expect a ValueError on Unix, but not on Windows
+ if not sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should raise ValueError.")
+ m.close()
+ finally:
+ f.close()
if sys.platform.startswith('win'):
- f.close()
+ # Repair damage from the resizing test.
f = open(TESTFN, 'r+b')
f.truncate(mapsize)
f.close()
- self.fail("Opening mmap with size+1 should work on Windows.")
- else:
- # we expect a ValueError on Unix, but not on Windows
- if not sys.platform.startswith('win'):
- self.fail("Opening mmap with size+1 should raise ValueError.")
- m.close()
- f.close()
- if sys.platform.startswith('win'):
- # Repair damage from the resizing test.
- f = open(TESTFN, 'r+b')
- f.truncate(mapsize)
- f.close()
# Opening mmap with access=ACCESS_WRITE
f = open(TESTFN, "r+b")
More information about the pypy-commit
mailing list