From 9441998ecf93a4fa1fa0dc03f1ac14ade0ccee03 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Mon, 28 Mar 2016 10:37:03 -0600 Subject: [PATCH] Close file handle before passing edit's tempfile to editor. PR #416 --- jrnl/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index f6a7735f..446682b4 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -163,11 +163,11 @@ def get_text_from_editor(config, template=""): with codecs.open(tmpfile, 'w', "utf-8") as f: if template: f.write(template) + os.close(filehandle) # remove process lock on temp file subprocess.call(shlex.split(config['editor'], posix="win" not in sys.platform) + [tmpfile]) with codecs.open(tmpfile, "r", "utf-8") as f: raw = f.read() - os.close(filehandle) - os.remove(tmpfile) + os.remove(tmpfile) # delete temp file if not raw: prompt('[Nothing saved to file]') return raw