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.calcsize() behaves strangely with short type
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mwh, serzan
Priority: normal Keywords:

Created on 2004-09-08 21:00 by serzan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg22395 - (view) Author: Serafeim Zanikolas (serzan) Date: 2004-09-08 21:00
Example: 
from struct import calcsize 
calcsize('h') reports 2 
calcsize('i') reports 4, but 
calcsize('hi') reports 8! (same with calcsize('hhi')) 
 
Am I missing something or isn't it the case that calcsize('h') should 
report 4? 
 
python version: 
Python 2.3.3 (#1, May 25 2004, 16:51:30) 
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 
uname -a output: 
Linux XXXX 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT 2004 i686 
i686 i386 GNU/Linux 
msg22396 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-09-09 12:03
Logged In: YES 
user_id=6656

struct defaults to "native" alignment.  Try starting your
format string with "=".

This is documented, so closing.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40885
2004-09-08 21:00:29serzancreate