提交 f156b5b5 编写于 作者: G George McCollister 提交者: Simon Glass

dtoc: Decode val if it's a byte string

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: NGeorge McCollister <george.mccollister@gmail.com>
Acked-by: NSimon Glass <sjg@chromium.org>
上级 6db06f94
......@@ -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]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册