> -----Original Message----- > > No, that's not the case at all. As Antoine explains in the issue, there are > plenty of ways in which Python code can be run when breaking a cycle. Not > only weakrefs, but also objects released as a consequence of tp_clear which > weren't *in* the cycle (but hung from it). I see, that makes sense. The rule is, then that we cannot delete objects with finalalizer, that can reach other garbage, simply because doing so may find the objects in an unexpected (cleared) state and thus cause weird errors. (weakrefs are a special case, apparently dealt with separately. And the callback cannot refer back to the referent) . This reasoning belongs in the gcmodule.c, I think. > > > So, I ask you: What is allowed during tp_clear()? Is this a hard > > rule? What is the reason? > > We are all consenting adults. Everything is allowed - you just have to live > with > the consequences.
Well, we specifically decided that objects with __del__ methods that are part of a cycle cannot be run. The same reasoning was applied to generators, if they are in a certain state. What makes iobase so special that its 'close' method can be run even if it is part of a cycle? Why not allow it for all objects, then? At the very least, I think this behaviour (this exception for iobase) merits being explicitly documented. Kristján _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com