[PATCH 1/2] bbremote: fix 'NoneType' object has no attribute 'encode'

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Dec 11 23:19:27 PST 2024


The RatpFSServer constructor supports passing None to it, but the
command line interface panics before the function can be invoked.

As the function already supports NoneType and bytes input, just teach it
to accept str input as well.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 scripts/remote/main.py   | 4 ++--
 scripts/remote/ratpfs.py | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/remote/main.py b/scripts/remote/main.py
index 5aa176fdc426..020a78c3fcb0 100644
--- a/scripts/remote/main.py
+++ b/scripts/remote/main.py
@@ -48,7 +48,7 @@ def get_controller(args):
 
 def handle_run(args):
     ctrl = get_controller(args)
-    ctrl.export(args.export.encode())
+    ctrl.export(args.export)
     res = ctrl.command(' '.join(args.arg))
     if res:
         res = 1
@@ -160,7 +160,7 @@ def handle_listen(args):
 def handle_console(args):
     queue = Queue()
     ctrl = get_controller(args)
-    ctrl.export(args.export.encode())
+    ctrl.export(args.export)
     ctrl.start(queue)
     ctrl.send_async_console(b'\r')
     cons = ConsoleInput(queue, exit=b'\x14')  # CTRL-T
diff --git a/scripts/remote/ratpfs.py b/scripts/remote/ratpfs.py
index 3e05cf241868..3aa3eb45ac78 100644
--- a/scripts/remote/ratpfs.py
+++ b/scripts/remote/ratpfs.py
@@ -60,6 +60,8 @@ class RatpFSPacket(object):
 class RatpFSServer(object):
     def __init__(self, path=None):
         if path:
+            if isinstance(path, str):
+                path = path.encode()
             assert isinstance(path, bytes)
             self.path = os.path.abspath(os.path.expanduser(path))
         else:
-- 
2.39.5




More information about the barebox mailing list