pyon/store_file: do not erase file when encoding fails

This commit is contained in:
Sebastien Bourdeauducq 2014-12-31 17:20:12 +08:00
parent cda394e0ce
commit 0aa450ad5d
1 changed files with 2 additions and 1 deletions

View File

@ -156,8 +156,9 @@ def store_file(filename, x):
"""Encodes a Python object and writes it to the specified file.
"""
contents = encode(x, True)
with open(filename, "w") as f:
f.write(encode(x, True))
f.write(contents)
def load_file(filename):