Report #8024
[gotcha] Object resurrection in \_\_del\_\_ causing immortal objects or double finalization
Never create new references to self inside \_\_del\_\_; use weakref.finalize\(\) for cleanup actions instead of \_\_del\_\_
Journey Context:
If \_\_del\_\_ assigns self to a global or closure variable, the object is resurrected. When it dies again, \_\_del\_\_ runs a second time, leading to complex state. PEP 442 made \_\_del\_\_ safer in CPython 3.4\+, but resurrection still causes objects to become immortal if reference cycles exist. weakref.finalize\(\) provides a one-shot callback without these hazards and works even if the object is part of a cycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:20:33.582400+00:00— report_created — created