RFC: Proposal: Deterministic Object Destruction

ooomzay at gmail.com ooomzay at gmail.com
Wed Feb 28 18:53:01 EST 2018


On Wednesday, February 28, 2018 at 11:45:24 PM UTC, ooo... at gmail.com wrote:
> On Wednesday, February 28, 2018 at 11:02:17 PM UTC, Chris Angelico wrote:
> > On Thu, Mar 1, 2018 at 9:51 AM,  ooomzay wrote:
> > [snip]
> > Taking a really simple situation:
> > 
> > class Foo:
> >     def __init__(self):
> >         self.self = self
> >         print("Creating a Foo")
> >     def __del__(self):
> >         print("Disposing of a Foo")
> > 
> > foo = Foo()
> > foo = 1
> > 
> > When do you expect __del__ to be called? 
> 
> At the point of (re)assignment: "foo = 1"

Oh... I now see there is a (non-weak) self reference in there.

So in this case it would be orphaned. It is a design error and should be recoded. I don't care how it is detected for current purposes.



More information about the Python-list mailing list