[Patches] [ python-Patches-925932 ] struct.pack() on 64bit architectures

SourceForge.net noreply at sourceforge.net
Tue Apr 10 18:45:14 CEST 2007


Patches item #925932, was opened at 2004-03-30 12:55
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=925932&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tests
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 5
Private: No
Submitted By: Aleksander Piotrowski (pelotas)
Assigned to: Nobody/Anonymous (nobody)
Summary: struct.pack() on 64bit architectures

Initial Comment:
I'm running python on OpenBSD/sparc64 (SUN Ultra 10).

On this machine struct.pack() gives me:

>>> struct.pack('l', 1)
'\x00\x00\x00\x00\x00\x00\x00\x01'
>>> struct.pack('i', 1)
'\x00\x00\x00\x01'

On i386 box I have:

>>> struct.pack('l', 1)
'\x01\x00\x00\x00'
>>> struct.pack('i', 1)
'\x01\x00\x00\x00'

Because of this, OpenBSD port uses attached patch. I
guess that this is generic problem (not OpenBSD
specific) and every 64bit platform would suffer.

Am I right?

----------------------------------------------------------------------

>Comment By: Ziga Seilnacht (zseil)
Date: 2007-04-10 18:45

Message:
Logged In: YES 
user_id=1326842
Originator: NO

test_fcntl was fixed in r38766 and r38767 to support
64bit BSD systems:

http://svn.python.org/view?rev=38766&view=rev

That fix is included in Python 2.4.2 and above.
Thanks for the patch anyway!

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-03-31 21:08

Message:
Logged In: YES 
user_id=21627

I don't quite understand the current code: struct flock is
on Darwin

struct flock {
        off_t   l_start;        /* starting offset */
        off_t   l_len;          /* len = 0 means until end
of file */
        pid_t   l_pid;          /* lock owner */
        short   l_type;         /* lock type: read/write,
etc. */
        short   l_whence;       /* type of l_start */
};

and off_t is

typedef int64_t         quad_t;
typedef quad_t          off_t;          /* file offset */

so it appears there is no padding at all. In any case,
this needs to be changed in posixfile._posixfile_.flock
accordingly.



----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2004-03-30 17:57

Message:
Logged In: YES 
user_id=31435

For a Unix-head reviewer:  the patch is to test_fcntl.py, 
which uses a native struct.pack() to build a lockdata 
argument for fcntl.  On the OP's box, it constructs stuff of 
the wrong size, due to "l" format codes producing 8-byte 
thingies.  The patch changes the "l" codes to "i" on the OP's 
platform.

I wonder whether we couldn't instead use "i" codes on all BSD-
ish platforms -- on 32-bit boxes, "i" is synonymous with "l", 
while on 64-bit boxes it looks like "l" is wrong but "i" is correct.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=925932&group_id=5470


More information about the Patches mailing list