[ python-Bugs-1024669 ] struct.calcsize() behaves strangely with short type

SourceForge.net noreply at sourceforge.net
Thu Sep 9 14:03:33 CEST 2004


Bugs item #1024669, was opened at 2004-09-08 22:00
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1024669&group_id=5470

Category: Extension Modules
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Serafeim Zanikolas (serzan)
Assigned to: Nobody/Anonymous (nobody)
Summary: struct.calcsize() behaves strangely with short type

Initial Comment:
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 

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

>Comment By: Michael Hudson (mwh)
Date: 2004-09-09 13:03

Message:
Logged In: YES 
user_id=6656

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

This is documented, so closing.

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

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


More information about the Python-bugs-list mailing list