New submission from Caleb Deveraux <[EMAIL PROTECTED]>:

I'm not exactly sure if this is a bug or by design.  Within the struct
module, whenever you provide a format string containing a repeat count
with no associated format specifier, the count is silently ignored.

eg.

>>> struct.pack("12345")
''
>>> struct.pack("3s42", "abc")
'abc'

(This also happens with unpack*, and pack_into)

The attached patch changes the above behavior to the following:

>>> struct.pack("12345")
struct.error: repeat count given without format specifier
>>> struct.pack("3s42", "abc")
struct.error: repeat count given without format specifier

Unit tests are included.

The attached patch is built against revision 64324 of the python SVN
trunk.  Odd behavior observed in both 2.6 (svn r64324), and 2.5.2.
(Tested on Ubuntu x86_64 w/ Linux kernel 2.6.24)

----------
components: Library (Lib)
files: patch.p0
messages: 68309
nosy: carrus85
severity: normal
status: open
title: struct allows repeat spec. without a format specifier
type: behavior
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file10643/patch.p0

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to