[rcw][PATCH 1/3] rcw.py: Fix indexing with floats

Sean Anderson <[email protected]> Tue, 5 Apr 2022 12:35:03 -0400
Newsgroups org.yoctoproject.lists.meta-freescale
Message-ID <[email protected]>
When creating a source PBI from a binary, the following error is
encountered:

> TypeError: slice indices must be integers or None or have an __index__ method

This is because division in python3 always returns a float. Instead, use
the integer division operator, which returns a (truncated) int.

Fixes: 7c47f30 ("Add support of Gen3 family SoCs")
Signed-off-by: Sean Anderson <[email protected]>
---

 rcw.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rcw.py b/rcw.py
index 863f755..266a44f 100755
--- a/rcw.py
+++ b/rcw.py
@@ -779,19 +779,19 @@ def create_source():
         if pbiformat == 2:
             if binary[0:4] == preambletst:
                 # Convert the binary into a large integer
-                rcw = binary[8:8 + (size / 8)]
+                rcw = binary[8:8 + (size // 8)]
                 bitbytes = rcw
                 # We skip the checksum field
-                pbi = binary[8 + (size / 8) + 4:]
+                pbi = binary[8 + (size // 8) + 4:]
             else:
                 print('Weird binary RCW format!')
                 bitbytes = ''
         else:
             if binary[0:4] == preambletst:
                 # Convert the binary into a large integer
-                rcw = binary[8:8 + (size / 8)]
+                rcw = binary[8:8 + (size // 8)]
                 bitbytes = rcw
-                pbi = binary[8 + (size / 8):]
+                pbi = binary[8 + (size // 8):]
             else:
                 print('Weird binary RCW format!')
                 bitbytes = ''
-- 
2.35.1.1320.gc452695387.dirty