[Python-Dev] struct.pack inconsistencies between platforms

pmon mail pmon.mail at gmail.com
Sun Feb 26 11:33:28 CET 2012


Hi

I have found myself in the following troubling situation.

I'm running the following code on a Python 2.6.5 on Linux x86:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> len(struct.pack('L',0))
4

Works as expected and documented (http://docs.python.org/library/struct.html
).

I'm running the same code on a MacPro (OS X 10.7.3) and I'm getting the
following:
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> len(struct.pack('L',0))
8

Documentation clearly states that the 'L' is a 4 byte integer.

Is this a bug? I'm I missing something?

Thanks
PMon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120226/777fe3f9/attachment.html>


More information about the Python-Dev mailing list