[New-bugs-announce] [issue7355] Struct incorrectly compiles format strings
report at bugs.python.org
Thu Nov 19 10:42:01 CET 2009
New submission from Steve Krenzel <sgk284 at gmail.com>:
The struct module has a calcsize() method which reports the size of the data for a specified format
string. In some instances, to the best of my knowledge, this is wrong.
>>> from struct import calcsize
The correct answer is 5 (a single byte character and a four byte int take up 5 bytes of space). For
some reason when a 'c' is followed by an 'i', this is wrong and instead allocates 4 bytes to the 'c'.
This has been verified in 2.6 and 2.5.
You can also repro this by using 's', '2c', and similar combinations in place of 'c'. as well as 'I'
in place of 'i'. This might effect other combinations as well.
components: Library (Lib)
title: Struct incorrectly compiles format strings
versions: Python 2.5, Python 2.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce