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

Message ID 20220405163507.3907691-2-sean.anderson@seco.com
State New
Headers show
Series Fix python 2->3 errors when using -r | expand

Commit Message

Sean Anderson April 5, 2022, 4:35 p.m. UTC
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 <sean.anderson@seco.com>
---

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

Patch

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 = ''