[elbe-devel] [PATCH] Python3: make archivedir's enbase compatible

bage at linutronix.de bage at linutronix.de
Mon Jan 20 20:49:45 CET 2020


From: Bastian Germann <bage at linutronix.de>

base64 input should be bytes, so open the file with the right flag.
Decode the (ASCII) output so that the following string concatenation works.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/archivedir.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elbepack/archivedir.py b/elbepack/archivedir.py
index fcff10888..785a8ac82 100644
--- a/elbepack/archivedir.py
+++ b/elbepack/archivedir.py
@@ -27,12 +27,12 @@ class ArchivedirError(Exception):
     pass
 
 def enbase(fname, compress=True):
-    infile = open(fname, "r")
+    infile = open(fname, "rb")
     s = infile.read()
     if compress:
         s = bz2compress(s)
 
-    enc = standard_b64encode(s)
+    enc = standard_b64encode(s).decode()
     splited = ""
     i = 0
     l_enc = len(enc)
-- 
2.20.1




More information about the elbe-devel mailing list