Message335405
When designing an extension type subclassing an existing type, it makes sense to call the tp_dealloc of the base class from the tp_dealloc of the subclass.
Now suppose that I'm subclassing "list" which uses the trashcan mechanism. Then it can happen that the tp_dealloc of list puts this object in the trashcan, even though the tp_dealloc of the subclass has already been called. Then the tp_dealloc of the subclass may be called multiple times, which is unsafe (tp_dealloc is expected to be called exactly once).
To solve this, the trashcan mechanism should be disabled when tp_dealloc is called from a subclass.
Interestingly, subtype_dealloc also solves this in a much more involved way (see the "Q. Why the bizarre (net-zero) manipulation of _PyRuntime.trash_delete_nesting around the trashcan macros?") in
Objects/typeobject.c |
|
Date |
User |
Action |
Args |
2019-02-13 11:02:31 | jdemeyer | set | recipients:
+ jdemeyer, pitrou, scoder |
2019-02-13 11:02:31 | jdemeyer | set | messageid: <1550055751.42.0.717332216151.issue35983@roundup.psfhosted.org> |
2019-02-13 11:02:31 | jdemeyer | link | issue35983 messages |
2019-02-13 11:02:31 | jdemeyer | create | |
|