diff mbox

[U-Boot,v2,03/10] patman: Don't convert input data to unicode

Message ID 20170529213132.21217-4-sjg@chromium.org
State Accepted
Commit 5c724dc4403c63b86fef8cccd2baa47cfa870986
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass May 29, 2017, 9:31 p.m. UTC
The communication filter reads data in blocks and converts each block to
unicode (if necessary) one at a time. In the unlikely event that a unicode
character in the input spans a block this will not work. We get an error
like:

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1022-1023:
   unexpected end of data

There is no need to change the input to unicode, so the easiest fix is to
drop this feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

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

Comments

Simon Glass June 7, 2017, 1:47 a.m. UTC | #1
The communication filter reads data in blocks and converts each block to
unicode (if necessary) one at a time. In the unlikely event that a unicode
character in the input spans a block this will not work. We get an error
like:

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1022-1023:
   unexpected end of data

There is no need to change the input to unicode, so the easiest fix is to
drop this feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

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

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index 7c76014340..ebd4300dfd 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -190,8 +190,6 @@  class Popen(subprocess.Popen):
                 # We will get an error on read if the pty is closed
                 try:
                     data = os.read(self.stdout.fileno(), 1024)
-                    if isinstance(data, bytes):
-                        data = data.decode('utf-8')
                 except OSError:
                     pass
                 if data == "":
@@ -207,8 +205,6 @@  class Popen(subprocess.Popen):
                 # We will get an error on read if the pty is closed
                 try:
                     data = os.read(self.stderr.fileno(), 1024)
-                    if isinstance(data, bytes):
-                        data = data.decode('utf-8')
                 except OSError:
                     pass
                 if data == "":