Antoine Pitrou added the comment: Looking into it, it's normal for refcounts to be "ignored": those objects belong to reference cycles:
tstgc.__dict__ -> p (or c, or c2) -> p.__class__ (i.e. Parent, or Child respectivel)) -> Parent.__dict__ -> Parent.__del__ (or Parent.__init__, or Parent.child) -> Parent.__del__.__globals__ (which is tstgc.__dict__) Since p, c, c2 belong to reference cycles, they get collected in an undefined order. Obviously, Parent.__del__ is buggy (it runs into an infinite loop when self.children != 0). Before Python 3.4, the module globals would have been set to None at shutdown, which would have broken those cycles, but caused other well-known problems. It's probably impossible to find a scheme that satisfies all constraints, so we'll see in the future if the new scheme brings more drawbacks than advantages (right now, my own evaluation is obviously that it's a step forward). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21351> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com