[Python-bugs-list] python dumps core on my script (PR#207)

vincent@ldsol.com vincent@ldsol.com
Wed, 16 Feb 2000 11:41:28 -0500 (EST)


On Wed, 16 Feb 2000, Guido van Rossum wrote:

> The problem is that the call to "print self" inside the __repr__()
> method causes a recursive call to __repr__().  This causes an
> unchecked stack overflow in C.

I guessed that about 3 minutes after sending the bug report... ;)

> You can avoid this by not calling "print self" inside __repr__().
> 
> We'll mark this as an open problem because Python should have given
> you a MemoryError as it tries to do with other stack overflows -- but
> catching stack overflows is hard.

I only found this one inadvertantly, but there are many more potential
problems, ie: print self in __str__, creating an object in __init__, or
even a loop involving (for example) __repr__ calling
__hash__, itself calling __repr__
But I imagine these cases are not only very hard to detect but may also 
be hard to fix in an efficient way...

NB: the script above that shown this bug was my first 'serious' python
program, but I'm not discouraged... ;)

	Cordialement,

-- 
"Si ca sent bon : mange-le, sinon pisse dessus..."  [Proverbe chien]