[Python-3000] Weird error message from bytes type

Neil Schemenauer nas at arctrix.com
Mon Feb 26 01:29:31 CET 2007

On Sun, Feb 25, 2007 at 05:40:12PM -0600, Guido van Rossum wrote:
> Thomas is correct. You can only assign ints in range(256) to a single
> index.

Yes, I understand that.  I think the error message is bad though.

> The error comes from the call to PyNumber_AsSsize_t() in
> bytes_setitem(), which apparently looks for __index__ or the tp_index
> slot.

I think PyNumber_AsSsize_t is being used on the RHS operand.  That's
perhaps convenient but makes for a confusing message.  There was
nothing wrong with the value I was using for an index.


More information about the Python-3000 mailing list