mkenums: Don't raise when unlinking a file that does not exist

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=789637
This commit is contained in:
Sam Spilsbury 2017-10-27 21:42:46 +08:00 committed by Philip Withnall
parent d31a7516a9
commit 34148fc9b9

View File

@ -708,5 +708,11 @@ write_output("\n" + comment + "\n")
if tmpfile is not None:
tmpfilename = tmpfile.name
tmpfile.close()
os.unlink(options.output)
try:
os.unlink(options.output)
except OSError as error:
if error.errno != errno.ENOENT:
raise error
os.rename(tmpfilename, options.output)