exception occurred so it should only be closed in the else clause.
Without this change we can an UnboundLocalError on Linux:
Traceback (most recent call last):
File "Lib/test/test_mmap.py", line 304, in ?
test_both()
File "Lib/test/test_mmap.py", line 208, in test_both
m.close()
UnboundLocalError: local variable 'm' referenced before assignment
# we expect a ValueError on Unix, but not on Windows
if not sys.platform.startswith('win'):
verify(0, "Opening mmap with size+1 should raise ValueError.")
- m.close()
+ m.close()
f.close()
if sys.platform.startswith('win'):
# Repair damage from the resizing test.