Fix temporary file handling
This commit fixes the handling of the temporary file used by the edit()
function. It ensures that there is no file name clashes in the name
of the temporary file and it gets rid of the hardcoded /tmp
location
of the temporary file. It also removes the file when it's no longer
needed.
Details:
-
Use
tempfile.NamedTemporaryFile()
(which usesmkstemp()
) for creating the temporarycommentfile
. -
Remove temporary file when done with it using
os.unlink()
.
Tested with Python 2.7/3.6 on OpenBSD.