From: Paul Burton Date: Tue, 27 Sep 2016 16:03:57 +0100 Subject: [U-Boot] [PATCH v2 09/10] dtoc: Decode strings for struct.unpack on python 3.x In-Reply-To: <20160927150358.6248-1-paul.burton@imgtec.com> References: <20160927150358.6248-1-paul.burton@imgtec.com> Message-ID: <20160927150358.6248-10-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 On python 3.x struct.unpack will complain if we provide it with a string since it expects to operate on a bytes object. In order to satisfy this requirement, encode the string to a bytes object when running on python 3.x. Signed-off-by: Paul Burton Acked-by: Simon Glass --- Changes in v2: None tools/dtoc/fdt_util.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index 3a10838..e6d523b 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -8,6 +8,7 @@ import os import struct +import sys import tempfile import command @@ -22,6 +23,8 @@ def fdt32_to_cpu(val): Return: A native-endian integer value """ + if sys.version_info > (3, 0): + val = val.encode('raw_unicode_escape') return struct.unpack('>I', val)[0] def EnsureCompiled(fname): -- 2.10.0