summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBoris Zanin <boris.zanin@mobica.com>2019-05-20 15:17:44 +0200
committerAlexander Galazin <Alexander.Galazin@arm.com>2019-05-29 08:26:07 -0400
commit512a25c871c3bf0dbc629d49ef30ed9ff5120353 (patch)
treec328de4dfd817d0a13a9a8ab45e77c731997f7fb /scripts
parent7b4b0d715aa4e8978bc628800e9f2274ef33be6f (diff)
downloadVK-GL-CTS-512a25c871c3bf0dbc629d49ef30ed9ff5120353.tar.gz
VK-GL-CTS-512a25c871c3bf0dbc629d49ef30ed9ff5120353.tar.bz2
VK-GL-CTS-512a25c871c3bf0dbc629d49ef30ed9ff5120353.zip
Python3 compatibility: end-of-lines
Python 3 writing text files silently replaces \n with \r\n under Windows. Text formatted files now need to be written in binary mode to avoid end-of-lines modification. Components: Framework VK-GL-CTS issue: 1665 Change-Id: I11e1521d815362b2263a809605f1e85c6dc27765
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/common.py5
-rw-r--r--scripts/khr_util/format.py6
2 files changed, 9 insertions, 2 deletions
diff --git a/scripts/build/common.py b/scripts/build/common.py
index cb17a239f..2ad5c74a3 100644
--- a/scripts/build/common.py
+++ b/scripts/build/common.py
@@ -105,7 +105,10 @@ def writeBinaryFile (filename, data):
f.close()
def writeFile (filename, data):
- f = open(filename, 'wt')
+ if (sys.version_info < (3, 0)):
+ f = open(filename, 'wt')
+ else:
+ f = open(filename, 'wt', newline='\n')
f.write(data)
f.close()
diff --git a/scripts/khr_util/format.py b/scripts/khr_util/format.py
index 0790d8d19..8c2fa1e01 100644
--- a/scripts/khr_util/format.py
+++ b/scripts/khr_util/format.py
@@ -21,6 +21,7 @@
#-------------------------------------------------------------------------
import os
+import sys
from itertools import chain
INL_HEADER_TMPL = """\
@@ -79,7 +80,10 @@ def readFile (filename):
def writeFileIfChanged (filename, data):
if not os.path.exists(filename) or readFile(filename) != data:
- f = open(filename, 'wt')
+ if (sys.version_info < (3, 0)):
+ f = open(filename, 'wt')
+ else:
+ f = open(filename, 'wt', newline='\n')
f.write(data)
f.close()