Skip to content

gh-153797: Fix possible crash when re-importing extension modules after OOM - #153798

Open
lpyu001 wants to merge 1 commit into
python:mainfrom
lpyu001:0020
Open

gh-153797: Fix possible crash when re-importing extension modules after OOM#153798
lpyu001 wants to merge 1 commit into
python:mainfrom
lpyu001:0020

Conversation

@lpyu001

@lpyu001 lpyu001 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

When _modules_by_index_set() fails while re-importing a legacy single-phase extension module, it may leave a MemoryError pending. The cleanup path previously called PyMapping_DelItem() with that exception still set, causing debug builds to abort when the deletion succeeded.
Use the existing remove_module() helper to preserve the original exception while removing the partially initialized module from sys.modules. This keeps the cleanup consistent with other import failure paths and prevents the interpreter crash.

Fix a crash that could occur after an out-of-memory error when re-importing
an extension module.
Sign up for free to 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