From 0aa450ad5d842171f00cb1df7564742cfca3ab4e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 31 Dec 2014 17:20:12 +0800 Subject: [PATCH] pyon/store_file: do not erase file when encoding fails --- artiq/management/pyon.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/artiq/management/pyon.py b/artiq/management/pyon.py index c231b63be..23d701bc7 100644 --- a/artiq/management/pyon.py +++ b/artiq/management/pyon.py @@ -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):