From mboxrd@z Thu Jan 1 00:00:00 1970 From: George McCollister Date: Thu, 30 Mar 2017 09:44:25 -0500 Subject: [U-Boot] [PATCH 2/2] dtoc: Decode val if it's a byte string In-Reply-To: <20170330144425.19997-1-george.mccollister@gmail.com> References: <20170330144425.19997-1-george.mccollister@gmail.com> Message-ID: <20170330144425.19997-2-george.mccollister@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de With Python 3.5.2 encode will throw an exception if val is a byte array. Decode it to a string first. This assumes it's utf-8, if it's not valid utf-8 it will throw an exception. Signed-off-by: George McCollister --- tools/dtoc/fdt_util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index e6d523b9de..b9dfae8d0e 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -24,6 +24,8 @@ def fdt32_to_cpu(val): A native-endian integer value """ if sys.version_info > (3, 0): + if isinstance(val, bytes): + val = val.decode('utf-8') val = val.encode('raw_unicode_escape') return struct.unpack('>I', val)[0] -- 2.11.0