When writing out an embedded script before running it, write it a line at a time to ensure line endings are UNIX-style.

This commit is contained in:
Greg Neagle
2016-01-26 14:22:52 -08:00
parent a885e52a54
commit 39cf5e8f52
+3 -1
View File
@@ -2617,7 +2617,9 @@ def writefile(stringdata, path):
Returns the path on success, empty string on failure.'''
try:
fileobject = open(path, mode='w', buffering=1)
print >> fileobject, stringdata.encode('UTF-8')
# write line-by-line to ensure proper UNIX line-endings
for line in stringdata.splitlines():
print >> fileobject, line.encode('UTF-8')
fileobject.close()
return path
except (OSError, IOError):