[PATCH v3 1/5] bbremote: Fix default payload value in BBPacket

Jules Maselbas jmaselbas at kalray.eu
Tue Feb 7 08:20:51 PST 2023

The payload variable is expected to typeof bytes, however the default
value in BBPacket contructor is of type str, a simple way to declare
a byte literal in Python is to prefix the string literal with `b`.

Signed-off-by: Jules Maselbas <jmaselbas at kalray.eu>
 scripts/remote/messages.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/remote/messages.py b/scripts/remote/messages.py
index 76cccad393..de15e72ed5 100644
--- a/scripts/remote/messages.py
+++ b/scripts/remote/messages.py
@@ -35,12 +35,13 @@ class BBType(object):
 class BBPacket(object):
-    def __init__(self, p_type=0, p_flags=0, payload="", raw=None):
+    def __init__(self, p_type=0, p_flags=0, payload=b"", raw=None):
         self.p_type = p_type
         self.p_flags = p_flags
         if raw is not None:
+            assert isinstance(payload, bytes)
             self.payload = payload
     def __repr__(self):

More information about the barebox mailing list