Skip to content

gh-151763: Fix dealloc clears the in-flight exception in subtype_dealloc - #153548

Open
Abhi210 wants to merge 1 commit into
python:mainfrom
Abhi210:gh-151763-0023
Open

gh-151763: Fix dealloc clears the in-flight exception in subtype_dealloc#153548
Abhi210 wants to merge 1 commit into
python:mainfrom
Abhi210:gh-151763-0023

Conversation

@Abhi210

Copy link
Copy Markdown
Contributor

Fixes: #gh-151763OOM-0023

subtype_dealloc() can clear the in-flight exception while tearing down heap-type instances. Unlike slot_tp_finalize(), this deallocation path does not preserve the current exception across operations that may perform arbitrary Py_DECREFs, potentially causing tstate->current_exception to be lost.

This patch saves the current exception before the destructive teardown (clear_slots(), managed dict clearing, base deallocation, and type decref) and restores it afterward, mirroring the existing exception-preservation pattern used in slot_tp_finalize().

@Abhi210Abhi210 changed the title BUG: Fix dealloc clears the in-flight exception in subtype_deallocgh-151763: Fix dealloc clears the in-flight exception in subtype_deallocJul 11, 2026
@Abhi210
Abhi210 marked this pull request as ready for review July 11, 2026 09:57
@Abhi210
Abhi210force-pushed the gh-151763-0023 branch 2 times, most recently from 70c3e1a to 8242da9CompareJuly 12, 2026 14:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Abhi210