freemyipod r929 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r928‎ | r929 | r930 >
Date:16:37, 20 May 2014
Author:theseven
Status:new
Tags:
Comment:
libemcorebootcfg: Fix Python 3.x problems
Modified paths:
  • /emcore/trunk/tools/libemcorebootcfg.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/libemcorebootcfg.py
@@ -24,7 +24,7 @@
2525 import struct
2626
2727 def encode(addr, option):
28 - if option == None: return ""
 28+ if option == None: return b""
2929 addr = addr + 16
3030 data1 = encode(addr, option[2])
3131 if len(data1) == 0: addr1 = 0
@@ -34,9 +34,9 @@
3535 if len(data2) == 0: addr2 = 0
3636 else: addr2 = addr
3737 addr = addr + len(data2)
38 - if type(option[1]).__name__ == "str":
39 - data = option[1] + '\0'
40 - data = data.ljust((len(data) + 3) & ~3, '\0')
 38+ if type(option[1]) == type(b""):
 39+ data = option[1] + b"\0"
 40+ data = data.ljust((len(data) + 3) & ~3, b"\0")
4141 else:
4242 data = ""
4343 addr = option[1]
@@ -44,7 +44,7 @@
4545
4646
4747 def configure(binary, options):
48 - fileaddr = binary.index("emCOboot")
 48+ fileaddr = binary.index(b"emCOboot")
4949 version = struct.unpack("<I", binary[fileaddr + 8 : fileaddr + 12])[0]
5050 if version != 1: raise ValueError("Unknown boot configuration data version")
5151 memaddr = struct.unpack("<I", binary[fileaddr + 12 : fileaddr + 16])[0]
@@ -52,4 +52,4 @@
5353 if len(data) == 0: addr = 0
5454 else: addr = memaddr + 24
5555 return binary[:fileaddr + 16] + struct.pack("<II", len(data) + 24, addr) + data
56 -
\ No newline at end of file
 56+