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.

classification
Title: struct long type size
Type: behavior Stage:
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, Сергей.Ковба
Priority: normal Keywords:

Created on 2012-09-07 08:15 by Сергей.Ковба, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg169980 - (view) Author: Сергей Ковба (Сергей.Ковба) Date: 2012-09-07 08:15
Such code PackageFile.write(struct.pack( "l", PkgHdrSize)) have different behaviour on 32-bit and 64-bit systems.
In case 32-bit system it writes to file 4 bytes. and 8 bytes in case 64-bit system, but in http://docs.python.org/library/struct.html p.7.3.2.2 long type have strict 4-byte size.
msg169981 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-09-07 09:02
This is expected behaviour.  By default, struct.pack and struct.unpack use the *native* size and alignment.  Use "<l" if you want platform-independent behaviour.

Relevant docs:

http://docs.python.org/library/struct.html#byte-order-size-and-alignment
History
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60082
2012-09-07 09:02:13mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg169981

resolution: not a bug
2012-09-07 08:15:46Сергей.Ковбаcreate