[oe-commits] [openembedded-core] 14/24: oeqa/ssh: Avoid unicode decode exceptions

git at git.openembedded.org git at git.openembedded.org
Mon May 20 13:39:21 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch warrior
in repository openembedded-core.

commit 918e15e22c797d52d33c3399324e480aa1a2cc7f
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Wed May 1 08:00:00 2019 +0100

    oeqa/ssh: Avoid unicode decode exceptions
    
    This code really needs to be rewritten to not split potential
    multibyte characters, for now work around it to avoid exceptions like:
    
      File "/home/pokybuild/yocto-worker/qa-extras2/build/meta/lib/oeqa/core/target/ssh.py", line 211, in run
        data = reader.read(1024, 4096)
      File "/usr/lib64/python3.6/codecs.py", line 503, in read
        newchars, decodedbytes = self.decode(data, self.errors)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 0: invalid start byte
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
    Signed-off-by: Armin Kuster <akuster808 at gmail.com>
---
 meta/lib/oeqa/core/target/ssh.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 8ff1f6c..2adbb30 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -207,7 +207,7 @@ def SSHCall(command, logger, timeout=None, **opts):
                 logger.debug('time: %s, endtime: %s' % (time.time(), endtime))
                 try:
                     if select.select([process.stdout], [], [], 5)[0] != []:
-                        reader = codecs.getreader('utf-8')(process.stdout)
+                        reader = codecs.getreader('utf-8')(process.stdout, 'surrogatepass')
                         data = reader.read(1024, 4096)
                         if not data:
                             process.stdout.close()
@@ -234,7 +234,7 @@ def SSHCall(command, logger, timeout=None, **opts):
                 output += lastline
 
         else:
-            output = process.communicate()[0].decode("utf-8", errors='replace')
+            output = process.communicate()[0].decode("utf-8", errors='surrogatepass')
             logger.debug('Data from SSH call: %s' % output.rstrip())
 
     options = {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list