Python3 compatibility: whitespace validation fix
authorBoris Zanin <boris.zanin@mobica.com>
Wed, 19 Jun 2019 13:39:57 +0000 (15:39 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 25 Jun 2019 08:05:57 +0000 (04:05 -0400)
Make encoding independend from environment by enforcing ascii.
And ignore decoding errors (i.e. bytes with code greater 127)
due to they are not essential for whitespace validation.

Components: Framework

VK-GL-CTS issue: 1665

Change-Id: I140ed7ff520c651d38d53ff1a99665242c71d54b

scripts/src_util/check_whitespace.py

index a2371d8..b37c128 100644 (file)
@@ -25,7 +25,10 @@ from argparse import ArgumentParser
 from common import getChangedFiles, getAllProjectFiles, isTextFile
 
 def checkFileWhitespace (file):
-    f = open(file, 'rt')
+    if (sys.version_info < (3, 0)):
+        f = open(file, 'rt')
+    else:
+        f = open(file, 'rt', encoding="ascii", errors='replace')
     error = False
     for lineNum, line in enumerate(f):
         if line.endswith(" \n") or line.endswith("\t\n"):