Issue 925932: struct.pack() on 64bit architectures (original) (raw)

Issue925932

Created on 2004-03-30 10:55 by pelotas, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch-Lib_test_test_fcntl_py pelotas,2004-03-30 10:55
Messages (4)
msg45688 - (view) Author: Aleksander Piotrowski (pelotas) Date: 2004-03-30 10:55
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?
msg45689 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-03-30 15:57
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.
msg45690 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-03-31 19:08
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.
msg45691 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-04-10 16:45
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!
History
Date User Action Args
2022-04-11 14:56:03 admin set github: 40101
2004-03-30 10:55:25 pelotas create