[Python-Dev] can this overflow (list insertion)?

Trent Mick trentm@ActiveState.com
Sat, 12 Aug 2000 15:33:12 -0700


On Sun, Aug 13, 2000 at 12:24:39AM +0200, Vladimir Marangozov wrote:
> +0.
> 
> It could overflow but if it does, this is a bad sign about using a list
> for such huge amount of data.

Point taken.

> 
> And this is the second time in a week that I see an attempt to introduce
> a bogus counter due to post-increments embedded in an if statement!
>

If I read you correctly then I think that you are mistaking my intention. Do
you mean that I am doing the comparison *before* the increment takes place
here:

> > !       if (self->ob_size++ == INT_MAX) {
> > !               PyErr_SetString(PyExc_OverflowError,
> > !                       "cannot add more objects to list");
> > !               return -1;
> > !       }

That is my intention. You can increment up to INT_MAX but not over.....

... heh heh actually my code *is* wrong. But for a slightly different reason.
I trash the value of self->ob_size on overflow. You are right, I made a
mistake trying to be cute with autoincrement in an 'if' statement. I should
do the check and *then* increment if okay.

Thanks,
Trent

-- 
Trent Mick
TrentM@ActiveState.com