[issue14897] struct.pack raises unexpected error message
Serhiy Storchaka
report at bugs.python.org
Thu May 24 11:33:34 CEST 2012
Serhiy Storchaka <storchaka at gmail.com> added the comment:
> It might help if the error message also stated how many arguments were actually received, like the TypeError message already does for bad function / method calls. E.g.,
>
> "struct.error: pack expected 2 items for packing (got 1)"
Yes, this would be useful. But seldom implemented.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string
>>> '%s %s'%(123,456,789)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
struct.pack also inconsistent in other error messages.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
struct.error: argument for 's' must be a bytes object
>>> struct.pack('i', '123')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
struct.error: required argument is not an integer
For "s" is mentioned format, and for "i" no. It would be helpful to
mention also the number of the item.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14897>
_______________________________________
More information about the Python-bugs-list
mailing list