bpo-35983: improve and test old trashcan macros by jdemeyer · Pull Request #12607 · python/cpython
I see what you mean. Let me be very precise what this PR will fix and what it will break, hopefully clarifying things:
This will fix a crash in this case:
- class
XusesPy_TRASHCAN_SAFE_BEGINin its deallocator - a class
Yinherits fromX - a 50 levels deep nested instance of
Yis deallocated
This will add a new crash in this case:
- class
XusesPy_TRASHCAN_SAFE_BEGINin its deallocator - class
Xdoes not inherit directly fromobject, but from another base class - a very deeply nested instance of
Xis deallocated, where this nesting does not involve any other trashcan-using class liketupleorlist
I consider the first set of conditions more likely than the second, so this will fix more crashes than it introduces. But I cannot deny the possibility that it will break stuff.