[Python-3000] Weird error message from bytes type

Guido van Rossum guido at python.org
Mon Feb 26 01:39:16 CET 2007

Correct (I wasn't saying it was used on the lhs operand :-).

I find it important to use that API since anything that wants to
behave like a (small) int should be acceptable. Can you suggest a
better way to formulate the error from that API?


On 2/25/07, Neil Schemenauer <nas at arctrix.com> wrote:
> 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.
>   Neil

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list