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

Paul Burton paul.burton at imgtec.com
Tue Sep 27 17:03:53 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>
Acked-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 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