Duncan Booth wrote:

 DB>  I figured out what is going on in the code to deallocate an old-style 
class 
 DB>  instance:
 DB> 
 DB>  The reference count is temporarily incremented.
 DB> 
 DB>  If the class has a __del__ method then a descriptor is created for the 
 DB>  method and called. When the call returns, the descriptor is released.
 DB> 
 DB>  Then the object itself is released using special code to avoid a 
recursive 
 DB>  call to the deallocator.
 DB> 
 DB>  However, if the trashcan mechanism is invoked by the attempt to release 
the 
 DB>  descriptor, it actually queues the descriptor in the trashcan. Since the 
 DB>  descriptor contains a reference to the object it has effectively 
 DB>  resurrected it. This means the special code to avoid the recursive call 
 DB>  simply decrements the reference count but does not release anything (the 
 DB>  object has been resurrected by the descriptor). When the descriptor is 
 DB>  later released the __del__ method is triggered a second time.

Thank You for so detailed explanation!
-- 
GMT More Then ...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to