[U-Boot] [PATCH 5/9] patman: Decode stdout/stderr as utf8, be python 3.x safe

Paul Burton paul.burton at imgtec.com
Mon Sep 26 16:30:31 CEST 2016


In python 3.x reading stdout or stdin will produce a bytestring rather
than a string. Decode it in CommunicateFilter such that the rest of the
code can continue to deal with strings. This works fine with python 2.x
too.

Signed-off-by: Paul Burton <paul.burton at imgtec.com>
---

 tools/patman/cros_subprocess.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index ebd4300..922e560 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -189,7 +189,7 @@ class Popen(subprocess.Popen):
                 data = ""
                 # We will get an error on read if the pty is closed
                 try:
-                    data = os.read(self.stdout.fileno(), 1024)
+                    data = os.read(self.stdout.fileno(), 1024).decode('utf8')
                 except OSError:
                     pass
                 if data == "":
@@ -204,7 +204,7 @@ class Popen(subprocess.Popen):
                 data = ""
                 # We will get an error on read if the pty is closed
                 try:
-                    data = os.read(self.stderr.fileno(), 1024)
+                    data = os.read(self.stderr.fileno(), 1024).decode('utf8')
                 except OSError:
                     pass
                 if data == "":
-- 
2.10.0



More information about the U-Boot mailing list