> Suppose 'list' is a self-referential list:
>
> list <=> [o, <list>]
>
> Suppose the refcount on 'o' is 1 and the refcount on 'list' is 1
> (i.e. the only reference to 'list' is its own internal
> reference). Then setting list[1] will drop the refcount on 'list' to
> 0, which drops the refcount on 'o' to 0, so both are
> garbage-collected.
>
> What I'm unsure of is: if you've been managing your refcounts
> correctly, can the initial condition (refcount of list is 1) ever
> occur?
and Donald Beaudry has a similar theory. Sorry folks, this isn't it!
The occurrence of list in itself and the initial reference to it are
two distinct references, so the reference count of the list is at
least 2. (Anyway, the bug would then be in the setlistitem() and not
in the next line.)
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>