Skip to content

Conversation

@freider
Copy link
Contributor

@freider freider commented Dec 19, 2025

Proxying of __del__ causes the destructor of the wrapped object to be run when the wrapper instance is deleted, which is bad for several reasons:

  • It may run while the implementation object is still being used somewhere, breaking the implementation assumptions about properties/resources
  • It will run twice, because the implementation class' __del__ will still run when the implementation is gc:ed, so it will assume that all __del__ implementations are idempotent, or risk breaking things

Copy link
Contributor

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@freider freider merged commit e1b7f08 into main Dec 19, 2025
12 checks passed
@freider freider deleted the freider/prevent-double-del branch December 19, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants