[issue7273] struct.pack adding extra '\x00' character in very specific case
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)
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)
title: struct.pack adding extra '\x00' character in very specific case
versions: Python 2.5, Python 2.6, Python 3.0
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list