freemyipod r851 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r850‎ | r851 | r852 >
Date:21:29, 1 January 2012
Author:theseven
Status:new
Tags:
Comment:
emcore.py: Make hexdump python3-aware
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -296,7 +296,7 @@
297297 if i >= 0 and i < size:
298298 w = 0
299299 for b in range(wordsize):
300 - w = w | (struct.unpack("B", data[i + b])[0] << (8 * b))
 300+ w = w | (struct.unpack("B", data[i + b : i + b + 1])[0] << (8 * b))
301301 sys.stdout.write(((" %%0%dX" if zeropad else " %%%dX") % (wordsize * 2)) % w)
302302 else: sys.stdout.write(" " * (wordsize * 2 + 1))
303303 if ascii:
@@ -304,7 +304,8 @@
305305 for i in range(r, r + wordsize * width):
306306 if i - r > 0 and (i - r) % asciisep == 0: sys.stdout.write(" ")
307307 if i >= 0 and i < size:
308 - if ord(data[i]) > 0x1f: sys.stdout.write(data[i])
 308+ if ord(data[i : i + 1]) > 0x1f and ord(data[i : i + 1]) < 0x80:
 309+ sys.stdout.write(data[i : i + 1].decode("latin1"))
309310 else: sys.stdout.write(asciirep)
310311 else: sys.stdout.write(" ")
311312 sys.stdout.write("|")