From e7dccb090786794b44213d3add032e484777726d Mon Sep 17 00:00:00 2001 From: "Marty E. Plummer" Date: Fri, 10 May 2019 01:38:11 -0500 Subject: securityRegListGen: use io.open and read in text mode. io.open is compatible with python3.x's open builtin. Open in text mode (no 'b') as this is a plain csv file, and specify the encoding as utf8. Without this change, building with python3.x (python3.5 tested) as /usr/bin/python will result in the following error: File "sbe/src/build/security/securityRegListGen.py", line 695, in main(sys.argv) File "sbe/src/build/security/securityRegListGen.py", line 592, in main for idx, row in enumerate(reader): File "/usr/lib/python3.5/csv.py", line 109, in __next__ self.fieldnames File "/usr/lib/python3.5/csv.py", line 96, in fieldnames self._fieldnames = next(self.reader) _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?) Change-Id: Ib86ea774b40c89e83ab1c0474014222f2fe9ddb9 Signed-off-by: Marty E. Plummer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/89386 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Srikantha S. Meesala Reviewed-by: RAJA DAS --- src/build/security/securityRegListGen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/build/security/securityRegListGen.py b/src/build/security/securityRegListGen.py index 4703c9be..c4324498 100644 --- a/src/build/security/securityRegListGen.py +++ b/src/build/security/securityRegListGen.py @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2017,2019 +# Contributors Listed Below - COPYRIGHT 2017,2020 # [+] International Business Machines Corp. # # @@ -26,6 +26,7 @@ import getopt import sys import os import csv +import io # Exit codes SUCCESS = 0 @@ -585,7 +586,7 @@ def main(argv): whitelist = [] blacklist = [] greylist = [] - with open(SECURITY_LIST, 'rbU') as f: + with io.open(SECURITY_LIST, 'r', encoding="utf8") as f: reader = csv.DictReader(f) for idx, row in enumerate(reader): try: -- cgit v1.2.1