[Tutor] Strange IndexError

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jun 1 19:09:50 CEST 2005

On Wed, 1 Jun 2005, Willi Richert wrote:

> in my code I get in rare occasions an IndexError which is
> incomprehensible to me in that situation, where I do a simple
> comparison:
> NeedBrain.py:233: RuntimeWarning: tp_compare didn't return -1 or -2 for
> exception
>   self._isNearMarker = self._markerDist < self.STAY_MIN_DIST

Hi Willi,

Hmmm!  This actually looks very unusual.  You should never see anything
about 'tp_compare' unless you're dealing with a buggy C extension.

> Traceback (most recent call last):
>   File "NeedBrain.py", line 233, in update
>     self._isNearMarker = self._markerDist < self.STAY_MIN_DIST
> IndexError: tuple assignment index out of range
> I don't see, where tuples are involved. I only compare two floats. I've
> Python 2.3.4.

Have you edited the program since the program started?  It's very possible
that the line numbers are wrong just because the program has changed in
the meantime.

But the warning before that talks about 'tp_compare' has me intrigued, as
you should never see that error.  If you don't mind, can you post your
code up somewhere?

Best of wishes to you!

More information about the Tutor mailing list