Title: struct.unpack
Type: behavior Stage:
Components: Versions: Python 2.7, Python 2.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Andres.Adjimann, tim.peters
Priority: normal Keywords:

Created on 2013-07-31 19:41 by Andres.Adjimann, last changed 2013-07-31 20:33 by Andres.Adjimann. This issue is now closed.

Messages (3)
msg194009 - (view) Author: Andres Adjimann (Andres.Adjimann) Date: 2013-07-31 19:41
There is something wrong with struct.unpack.

import struct
print struct.calcsize('<BBBBBHB')
print struct.calcsize('>BBBBBHB')
print struct.calcsize('BBBBBHB')
msg194016 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2013-07-31 20:29
Looks fine to me.  The third one uses native size and alignment (see the "Byte Order, Size, and Alignment" section of the struct docs).  After the first 5 B's, a pad byte is inserted so that the next H is properly aligned (to a 2-byte boundary).  That makes 6 bytes so far.  H then takes 2 bytes, making 8 bytes so far.  The final B adds the 9th byte.  As the docs say, < and > do no padding, so no pad byte is added in the first two cases.
msg194017 - (view) Author: Andres Adjimann (Andres.Adjimann) Date: 2013-07-31 20:33
sorry my bad.
Date User Action Args
2013-07-31 20:33:30Andres.Adjimannsetstatus: open -> closed
resolution: not a bug
messages: + msg194017
2013-07-31 20:29:32tim.peterssetnosy: + tim.peters
messages: + msg194016
2013-07-31 19:41:06Andres.Adjimanncreate