From: Paul Burton Date: Tue, 27 Sep 2016 16:03:53 +0100 Subject: [U-Boot] [PATCH v2 05/10] patman: Decode stdout/stderr as utf8, be python 3.x safe In-Reply-To: <20160927150358.6248-1-paul.burton@imgtec.com> References: <20160927150358.6248-1-paul.burton@imgtec.com> Message-ID: <20160927150358.6248-6-paul.burton@imgtec.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Acked-by: Simon Glass --- 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