Close file handle before passing edit's tempfile to editor.

PR #416
This commit is contained in:
MinchinWeb 2016-03-28 10:37:03 -06:00
parent 126e188c0f
commit 9441998ecf

View file

@ -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