From d4257771131b791cb5cd18a56fbab0b2a2d72eae Mon Sep 17 00:00:00 2001 From: Boris Zanin Date: Wed, 19 Jun 2019 15:39:57 +0200 Subject: [PATCH] Python3 compatibility: whitespace validation fix 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/src_util/check_whitespace.py b/scripts/src_util/check_whitespace.py index a2371d8..b37c128 100644 --- a/scripts/src_util/check_whitespace.py +++ b/scripts/src_util/check_whitespace.py @@ -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"): -- 2.7.4