fileutil.py: use try/finally to close file in write_atomically.

This commit is contained in:
david-sarah 2012-05-16 23:08:39 +00:00
parent 959248cd49
commit 3738c3e2d1

View File

@ -249,8 +249,10 @@ def move_into_place(source, dest):
def write_atomically(target, contents, mode="b"):
f = open(target+".tmp", "w"+mode)
f.write(contents)
f.close()
try:
f.write(contents)
finally:
f.close()
move_into_place(target+".tmp", target)
def write(path, data):