[Python-Dev] RE: CVS Python is unstable

Fred L. Drake, Jr. fdrake@acm.org
Fri, 23 Mar 2001 10:35:24 -0500 (EST)


Neil Schemenauer writes:
 > I'm not sure what you mean by "no longer a container".  If the
 > object defines the GC type flag the GC thinks its a container.

  Given the assumptions you describe, removing the object from the
list isn't sufficient to not be a container.  ;-(  In which case
reverting the change (as Tim did) is probably the only way to do it.
  What I was looking for was a way to remove the weakref object from
the set of containers sooner, but appearantly that isn't possible as
long as the object's type is the only used to determine whether it is
a container.

 > I believe your problems are deeper than this.  If
 > PyObject_IS_GC(op) is true and op is reachable from other objects

  And this only considers the object's type; the object can't be
removed from the set of containers by call PyObject_GC_Fini().  (It
clearly can't while tp_clear is active for that object!)

 > known to the GC then op must be in the linked list.  I haven't
 > tracked down all the locations in gcmodule where this assumption
 > is made but visit_reachable is one example.

  So it's illegal to call PyObject_GC_Fini() anywhere but from the
destructor?  Please let me know so I can make this clear in the
documentation!

 > We could remove this restriction if we were willing to accept
 > some slowdown.  One way would be to add the invariant
 > (gc_next == NULL) if the object is not in the GC list.  PyObject_Init
 > and gc_list_remove would have to set this pointer.  Is it worth
 > doing?

  It's not at all clear that we need to remove the restriction --
documenting it would be required.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Digital Creations