mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
dtoc: Decode strings for struct.unpack on python 3.x
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 <paul.burton@imgtec.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import command
|
import command
|
||||||
@@ -22,6 +23,8 @@ def fdt32_to_cpu(val):
|
|||||||
Return:
|
Return:
|
||||||
A native-endian integer value
|
A native-endian integer value
|
||||||
"""
|
"""
|
||||||
|
if sys.version_info > (3, 0):
|
||||||
|
val = val.encode('raw_unicode_escape')
|
||||||
return struct.unpack('>I', val)[0]
|
return struct.unpack('>I', val)[0]
|
||||||
|
|
||||||
def EnsureCompiled(fname):
|
def EnsureCompiled(fname):
|
||||||
|
Reference in New Issue
Block a user