[U-Boot] [U-Boot, v2, 5/8] test/py: Encode/decode strings for stdio

Tom Rini trini at konsulko.com
Fri Sep 22 00:41:20 UTC 2017


On Thu, Sep 14, 2017 at 02:34:47PM -0700, Paul Burton wrote:

> When reading stdin python 3.x will give us byte arrays, and when writing
> stdout or stderr it will expect byte arrays. In order to insulate the
> rest of the code from this difference, call encode or decode at
> appropriate points when reading or writing stdio files. This works fine
> on python 2.x too.
> 
> Signed-off-by: Paul Burton <paul.burton at imgtec.com>
> Reviewed-by: Stephen Warren <swarren at nvidia.com>

OK, this almost works.  When I add in the following only the vboot test
fails and I can't understand why:

diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index 21bdcb730917..d23bec0b9668 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -326,7 +326,7 @@ $(document).ready(function () {
 
         data = data.replace(chr(13), '')
         data = ''.join((c in self._nonprint) and ('%%%02x' % ord(c)) or
-                       c for c in data)
+                       c for c in data.encode('utf-8'))
         data = cgi.escape(data)
         return data
 
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index 751302a529e8..0490230c83dc 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -136,7 +136,7 @@ class Spawn(object):
         """
 
         for pi in range(len(patterns)):
-            if type(patterns[pi]) == type(''):
+            if type(patterns[pi]) != type(re.compile('')):
                 patterns[pi] = re.compile(patterns[pi])
 
         tstart_s = time.time()

Please run 'make tests' on a host with python==python2, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170921/55ca55dd/attachment.sig>


More information about the U-Boot mailing list