Author jdemeyer
Recipients jdemeyer, pitrou, scoder
Date 2019-02-13.11:02:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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 
Date User Action Args
2019-02-13 11:02:31jdemeyersetrecipients: + jdemeyer, pitrou, scoder
2019-02-13 11:02:31jdemeyersetmessageid: <>
2019-02-13 11:02:31jdemeyerlinkissue35983 messages
2019-02-13 11:02:31jdemeyercreate