Sure looks like a bug. It looks like Jython is putting in 4 bytes of padding before that last 64-bit number ("Q") to align it on a 64-bit boundary. But this doc:

 

http://docs.python.org/lib/module-struct.html

 

clearly states that with the "!" mode, sign and alignment are "standard", meaning no padding is added to align objects.

 

David H

 

From: jython-users-bounces@lists.sourceforge.net [mailto:jython-users-bounces@lists.sourceforge.net] On Behalf Of Sting
Sent: Tuesday, March 04, 2008 10:02 PM
To: jython-users@lists.sourceforge.net
Subject: [Jython-users] A strange result on struct.pack() in jython 2.2.1

 

Hi, I got a very strange result when use struct.pack(). Please see the following code segment:

import struct
dataunits = struct.pack('!HHIIIBBHQ', 0x20, 0x1c, 0xffffffff, 0x00000000, 0x0233, 0x05, 0x00, 0x0000, 0x1234)
print len(dataunits)
dataunits = struct.pack('!HHIIIBBH', 0x20, 0x1c, 0xffffffff, 0x00000000, 0x0233, 0x05, 0x00, 0x0000)
print len(dataunits)
s = struct.pack('!Q', 0x1234)
print len(s)

In jython, the result is: 32, 20, 8 while in python, the result is: 28, 20, 8.
Is it a bug?

--
Best regards!
-Sting