From 04a2b51f4c21e763ed9f0714b61360bdd69370a5 Mon Sep 17 00:00:00 2001 From: "Marty E. Plummer" Date: Fri, 10 May 2019 03:12:09 -0500 Subject: sbeCompression: use floor division python2 returns an integer when both division operands are integers. python3 will return a float in this situation. Use the floor division operator (//) which returns an integer on both versions. Without this change, building with python3.x (python3.5 tested) as /usr/bin/python will result in the following error: Traceback (most recent call last): File "sbe/src/boot/sbeCompression.py", line 198, in main( sys.argv ) File "sbe/src/boot/sbeCompression.py", line 181, in main compress(imagePath + "/" + image + ".base", imagePath + "/" + image + ".base.compressed") File "sbe/src/boot/sbeCompression.py", line 58, in compress for i in range(0, os.stat(inputFile).st_size / 4 ): TypeError: 'float' object cannot be interpreted as an integer Change-Id: Ibd63e9d2739eb6cf23d79d739237537e05932b15 Signed-off-by: Marty E. Plummer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/89371 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Srikantha S. Meesala Reviewed-by: RAJA DAS --- src/boot/sbeCompression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/boot/sbeCompression.py b/src/boot/sbeCompression.py index 82ec90ca..61ce0057 100755 --- a/src/boot/sbeCompression.py +++ b/src/boot/sbeCompression.py @@ -54,7 +54,7 @@ def compress(inputFile, compressedFile): sys.exit(1) instDict = dict() - for i in range(0, os.stat(inputFile).st_size / 4 ): + for i in range(0, os.stat(inputFile).st_size // 4 ): fourByt = f.read(4) @@ -90,7 +90,7 @@ def compress(inputFile, compressedFile): count = 0 #Create a bitmap for each four bytes of binary. - for i in range(0, os.stat(inputFile).st_size / 4 ): + for i in range(0, os.stat(inputFile).st_size // 4 ): fourByt = f.read(4) if fourByt in instList: @@ -99,7 +99,7 @@ def compress(inputFile, compressedFile): else : strBits += '0' - if ((len(strBits) == 32) or (i == (os.stat(inputFile).st_size / 4) - 1)): + if ((len(strBits) == 32) or (i == (os.stat(inputFile).st_size // 4) - 1)): value = int(strBits, 2) fW.write(struct.pack('>I', value)) strBits = "" @@ -117,7 +117,7 @@ def compress(inputFile, compressedFile): f.seek(0, 0) - for i in range(0, os.stat(inputFile).st_size / 4 ): + for i in range(0, os.stat(inputFile).st_size // 4 ): fourByt = f.read(4) -- cgit v1.2.1