meta-freescale.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [rcw][PATCH 0/3] Fix python 2->3 errors when using -r
@ 2022-04-05 16:35 Sean Anderson
  2022-04-05 16:35 ` [rcw][PATCH 1/3] rcw.py: Fix indexing with floats Sean Anderson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sean Anderson @ 2022-04-05 16:35 UTC (permalink / raw)
  To: meta-freescale, Yangbo Lu, Wasim Khan, Prabhakar Kushwaha
  Cc: Zhenhua Luo, Ting Liu, Shawn Guo, Jun Zhu, Alison Wang,
	Priyanka Jain, Otavio Salvador, Rajesh Bhagat, Leo Li,
	Pramod Kumar, Mingkai Hu, Sean Anderson

Although 3f744d3 ("Convert to python3") converted most of rcw.py to
python 3, the -r path remains unconverted. This series addresses the
issues I ran into when using this flag.


Sean Anderson (3):
  rcw.py: Fix indexing with floats
  rcw.py: Fix using ord on ints
  rcw.py: Append to pbi with a bytestring

 rcw.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.35.1.1320.gc452695387.dirty



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [rcw][PATCH 1/3] rcw.py: Fix indexing with floats
  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
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-04-05 16:35 UTC (permalink / raw)
  To: meta-freescale, Yangbo Lu, Wasim Khan, Prabhakar Kushwaha
  Cc: Zhenhua Luo, Ting Liu, Shawn Guo, Jun Zhu, Alison Wang,
	Priyanka Jain, Otavio Salvador, Rajesh Bhagat, Leo Li,
	Pramod Kumar, Mingkai Hu, Sean Anderson

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [rcw][PATCH 2/3] rcw.py: Fix using ord on ints
  2022-04-05 16:35 [rcw][PATCH 0/3] Fix python 2->3 errors when using -r Sean Anderson
  2022-04-05 16:35 ` [rcw][PATCH 1/3] rcw.py: Fix indexing with floats Sean Anderson
@ 2022-04-05 16:35 ` Sean Anderson
  2022-04-05 16:35 ` [rcw][PATCH 3/3] rcw.py: Append to pbi with a bytestring Sean Anderson
  2 siblings, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-04-05 16:35 UTC (permalink / raw)
  To: meta-freescale, Yangbo Lu, Wasim Khan, Prabhakar Kushwaha
  Cc: Zhenhua Luo, Ting Liu, Shawn Guo, Jun Zhu, Alison Wang,
	Priyanka Jain, Otavio Salvador, Rajesh Bhagat, Leo Li,
	Pramod Kumar, Mingkai Hu, Sean Anderson

Iterating over a bytestring will yield integers in python 3, so we don't
need to convert them with ord(). This avoids the following error:

> TypeError: ord() expected string of length 1, but int found

Fixes: 7c47f30 ("Add support of Gen3 family SoCs")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 rcw.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rcw.py b/rcw.py
index 266a44f..42a11dc 100755
--- a/rcw.py
+++ b/rcw.py
@@ -811,7 +811,7 @@ def create_source():
     # After this stage, all the RCW bits should be formatted with lsb on
     # the right side and msb on the left side to permit conversion into
     # a very long uint.
-    bitstring = ''.join(['{0:08b}'.format(ord(x)) for x in bitbytes])[::-1]
+    bitstring = ''.join(['{0:08b}'.format(x) for x in bitbytes])[::-1]
     bits = int(bitstring, 2)
 
     # Loop over all the known symbols
-- 
2.35.1.1320.gc452695387.dirty



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [rcw][PATCH 3/3] rcw.py: Append to pbi with a bytestring
  2022-04-05 16:35 [rcw][PATCH 0/3] Fix python 2->3 errors when using -r Sean Anderson
  2022-04-05 16:35 ` [rcw][PATCH 1/3] rcw.py: Fix indexing with floats Sean Anderson
  2022-04-05 16:35 ` [rcw][PATCH 2/3] rcw.py: Fix using ord on ints Sean Anderson
@ 2022-04-05 16:35 ` Sean Anderson
  2 siblings, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-04-05 16:35 UTC (permalink / raw)
  To: meta-freescale, Yangbo Lu, Wasim Khan, Prabhakar Kushwaha
  Cc: Zhenhua Luo, Ting Liu, Shawn Guo, Jun Zhu, Alison Wang,
	Priyanka Jain, Otavio Salvador, Rajesh Bhagat, Leo Li,
	Pramod Kumar, Mingkai Hu, Sean Anderson

Regular strings cannot be concatenated with byte strings. This fixes the
following error:

> TypeError: can't concat str to bytes

Fixes: 7c47f30 ("Add support of Gen3 family SoCs")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 rcw.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rcw.py b/rcw.py
index 42a11dc..fc58238 100755
--- a/rcw.py
+++ b/rcw.py
@@ -855,7 +855,7 @@ def create_source():
         l = len(pbi)
         # Deal reasonably with broken PBIs with, e.g., an extra LF
         # at the end
-        pbi += "\0\0\0"
+        pbi += b"\0\0\0"
         l += 3;
         l &= ~3;
         source += "\n.pbi\n"
-- 
2.35.1.1320.gc452695387.dirty



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-05 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 16:35 [rcw][PATCH 0/3] Fix python 2->3 errors when using -r Sean Anderson
2022-04-05 16:35 ` [rcw][PATCH 1/3] rcw.py: Fix indexing with floats Sean Anderson
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

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