[issue7189] struct.calcsize returns strange size

2009-10-23 Thread Igor Mikushkin

New submission from Igor Mikushkin igor.mikush...@gmail.com:

I think in second case struct size should be 53.

In [31]: struct.calcsize('ihhi35scc')
Out[31]: 49

In [32]: struct.calcsize('ihhi35scci')
Out[32]: 56

--
components: Library (Lib)
messages: 94379
nosy: igor.mikushkin
severity: normal
status: open
title: struct.calcsize returns strange size
type: behavior
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7189
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7189] struct.calcsize returns strange size

2009-10-23 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I think the calcsize result is correct here.  With the native struct 
format, padding is included in the struct.

In the second case, there are three bytes of padding after the 'cc' and 
before the 'i'.  This keeps the 'i' aligned on a 4-byte boundary.  If you 
look at the results of struct.pack, you can see the padding explicitly:

Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type help, copyright, credits or license for more information.
 import struct
 struct.pack('ihhi35scci', 123456789, 1, 1, 321456789, 
abcdefghijklmnopqrstuvwxyz123456789, '+', '*', 231456789)
\x15\xcd[\x07\x10'\x10'\x95\n)\x13abcdefghijklmnopqrstuvwxyz123456789+*\x
00\x00\x00\x15\xc0\xcb\r

--
nosy: +mark.dickinson
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7189
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com