Strange problem with structs Linux vs. Mac
jasonwiener
jasynwiener at gmail.com
Sun Mar 16 13:05:03 EDT 2008
Hi-
I am having a VERY odd problem with unpacking right now. I'm reading
data from a binary file and then using a very simple struct.unpack to
get a long. Works fine on my MacBook, but when I push it to a Linux
box,it acts differently and ends up pewking.
here's the code snippet:
fread.seek(0,0)
tmp_rebuild = fread.read()
fread.close()
tmp_long = tmp_rebuild[0:4]
print tmp_long.encode('hex')
print repr(tmp_long)
unpacked_long = struct.unpack('I', tmp_rebuild[0:4])[0]
print 'unpacked_long: %s' % unpacked_long
my MacBook produces:
1ec6f3b4
'\x1e\xc6\xf3\xb4'
unpacked_long: 516354996
but on the linux box the same code produces:
1ec6f3b4
'\x1e\xc6\xf3\xb4'
unpacked_long: 3035874846
the data looks to be the same, but the unpacking seems to treat it
differently.
Has anyone an idea of why this happens???
Thanks-
J.
More information about the Python-list
mailing list