This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rz
Recipients rz
Date 2013-06-08.19:22:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370719368.01.0.165210926264.issue18169@psf.upfronthosting.co.za>
In-reply-to
Content
Reproduction:

Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> struct.pack('!L', 0x01020304)
'\x01\x02\x03\x04'
>>> struct.pack('>L', 0x01020304)
'\x01\x02\x03\x04'
>>> struct.pack('<L', 0x01020304)
'\x04\x03\x02\x01'
>>> struct.pack('L', 0x01020304)
'\x04\x03\x02\x01\x00\x00\x00\x00' ### WAT??? ###
>>> 

As far as I see at the source code (http://hg.python.org/releasing/2.7.4/file/9290822f2280/Modules/_struct.c#l703), sizeof(long) is used as the size of 'L', which is equal to 8 at 64bit Linux...

The problem is that the results of packing with 'L' returns 8 bytes,
instead of 4 - as was expected from the documentation...
History
Date User Action Args
2013-06-08 19:22:48rzsetrecipients: + rz
2013-06-08 19:22:48rzsetmessageid: <1370719368.01.0.165210926264.issue18169@psf.upfronthosting.co.za>
2013-06-08 19:22:47rzlinkissue18169 messages
2013-06-08 19:22:47rzcreate