meta-freescale.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: meta-freescale@lists.yoctoproject.org,
	Yangbo Lu <yangbo.lu@nxp.com>, Wasim Khan <wasim.khan@nxp.com>,
	Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Cc: Zhenhua Luo <zhenhua.luo@nxp.com>, Ting Liu <ting.liu@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>, Jun Zhu <junzhu@nxp.com>,
	Alison Wang <alison.wang@nxp.com>,
	Priyanka Jain <priyanka.jain@nxp.com>,
	Otavio Salvador <otavio.salvador@ossystems.com.br>,
	Rajesh Bhagat <rajesh.bhagat@nxp.com>,
	Leo Li <leoyang.li@nxp.com>,
	Pramod Kumar <pramod.kumar_1@nxp.com>,
	Mingkai Hu <mingkai.hu@nxp.com>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [rcw][PATCH 1/3] rcw.py: Fix indexing with floats
Date: Tue,  5 Apr 2022 12:35:03 -0400	[thread overview]
Message-ID: <20220405163507.3907691-2-sean.anderson@seco.com> (raw)
In-Reply-To: <20220405163507.3907691-1-sean.anderson@seco.com>

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(-)

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



  reply	other threads:[~2022-04-05 17:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 16:35 [rcw][PATCH 0/3] Fix python 2->3 errors when using -r Sean Anderson
2022-04-05 16:35 ` Sean Anderson [this message]
2022-04-05 16:35 ` [rcw][PATCH 2/3] rcw.py: Fix using ord on ints Sean Anderson
2022-04-05 16:35 ` [rcw][PATCH 3/3] rcw.py: Append to pbi with a bytestring Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220405163507.3907691-2-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=alison.wang@nxp.com \
    --cc=junzhu@nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=meta-freescale@lists.yoctoproject.org \
    --cc=mingkai.hu@nxp.com \
    --cc=otavio.salvador@ossystems.com.br \
    --cc=prabhakar.kushwaha@nxp.com \
    --cc=pramod.kumar_1@nxp.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rajesh.bhagat@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=ting.liu@nxp.com \
    --cc=wasim.khan@nxp.com \
    --cc=yangbo.lu@nxp.com \
    --cc=zhenhua.luo@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).