mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 14:52:26 +00:00
fileutil.py: use try/finally to close file in write_atomically.
This commit is contained in:
parent
959248cd49
commit
3738c3e2d1
@ -249,8 +249,10 @@ def move_into_place(source, dest):
|
|||||||
|
|
||||||
def write_atomically(target, contents, mode="b"):
|
def write_atomically(target, contents, mode="b"):
|
||||||
f = open(target+".tmp", "w"+mode)
|
f = open(target+".tmp", "w"+mode)
|
||||||
f.write(contents)
|
try:
|
||||||
f.close()
|
f.write(contents)
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
move_into_place(target+".tmp", target)
|
move_into_place(target+".tmp", target)
|
||||||
|
|
||||||
def write(path, data):
|
def write(path, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user