Commit dcdc4e80 authored by Michael Büsch's avatar Michael Büsch

file write: Ignore unlink error, if file does not exist

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 3ef81cad
......@@ -118,7 +118,10 @@ def awlFileWrite(filename, data, encoding="latin_1"):
if not osIsPosix:
# Can't use safe rename on non-POSIX.
# Must unlink first.
os.unlink(filename)
try:
os.unlink(filename)
except OSError as e:
pass
os.rename(tmpFile, filename)
except (IOError, OSError, UnicodeError) as e:
raise AwlParserError("Failed to write file:\n" + str(e))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment