Delete partially-written file in the event of an error.

This commit is contained in:
Dan
2019-05-15 20:50:23 -04:00
committed by Wenzel Jakob
parent ede328a784
commit a163f8813e

View File

@@ -342,8 +342,17 @@ if __name__ == '__main__':
break
try:
if out_path:
with open(out_path, 'w') as out_file:
mkdoc(args, out_file)
try:
with open(out_path, 'w') as out_file:
mkdoc(args, out_file)
except:
# In the event of an error, don't leave a partially-written
# output file.
try:
os.unlink(out_path)
except:
pass
raise
else:
mkdoc(args)
except NoFilenamesError: