[New-bugs-announce] [issue7355] Struct incorrectly compiles format strings
Steve Krenzel
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.
To repro:
>>> from struct import calcsize
>>> calcsize("ci")
8
>>> calcsize("ic")
5
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)
messages: 95467
nosy: sgk284
severity: normal
status: open
title: Struct incorrectly compiles format strings
type: behavior
versions: Python 2.5, Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7355>
_______________________________________
More information about the New-bugs-announce
mailing list