[New-bugs-announce] [issue7273] struct.pack adding extra '\x00' character in very specific case
Caleb Madrigal
report at bugs.python.org
Fri Nov 6 17:16:36 CET 2009
New submission from Caleb Madrigal <caleb.madrigal at gmail.com>:
struct.pack("17scBH", 'a'*17, 'c', 255, 65535)
produces 'aaaaaaaaaaaaaaaaac\xff\x00\xff\xff'.
Notice the extra '\x00' character between '\xff' and '\xff\xff'.
I have noticed that this happens when there is an odd-length string
(like '17s'), followed by a character ('c'), followed by a byte ('B'),
followed by an unsigned short ('H').
Other variations reproduce it also (such as using a 19-character string).
However, if any one of the following modifications are made to the
format, the problem goes away:
* Change the string to 16s
* Remove the byte ('B')
* Remove the character ('c')
* Remove the unsigned short ('H')
So obviously, this is a seriously deep, dark corner-case.
----------
components: Library (Lib)
messages: 94980
nosy: cmadrigal
severity: normal
status: open
title: struct.pack adding extra '\x00' character in very specific case
type: behavior
versions: Python 2.5, Python 2.6, Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7273>
_______________________________________
More information about the New-bugs-announce
mailing list