3 ms·
Notably Python ignores exceptions thrown in __del__.
by blattimwind 8y ago
Notably Python ignores exceptions thrown in __del__.
- sytelus 8y agoAlso Python won’t call __del__ if there are circular references! And also there are no warnings if there re circular references.
- chrisseaton 8y ago> Also Python won’t call __del__ if there are circular references! Why not?
- blattimwind 8y agoPython uses cycle breaking i.e. it chooses an object on a circular path and simply deletes it, which essentially bricks the entire connected set for reference counting purposes. This means that if you ran __del__ code in this circumstance it could access references to deleted objects, i.e. use after free. __del__ is simply an unsound part of Python.
- chrisseaton 8y agoAh I assumed it marked, ran destructors, then swept.
- monochromatic 8y ago> Python doesn't know the order in which it's safe to destroy objects that hold circular references to each other, so as a design decision, it just doesn't call the destructors for such methods!